DataTable,DataRow,DataView sorting.

Hi all,

Just check the data sorting by using dataview in below.


SqlConnection sql=new SqlConnection("Connection String");
SqlCommand cmd=new SqlCommand("SampleProcedure",sql);
cmd.CommandType=CommandType.StoredProcedure;
SqlDataAdapter da=new SqlDataAdapter(cmd);
DataSet ds=new DataSet();
da.Fill(ds);
if(ds.Tables[0].Rows.Count>0)
{
DataTable dt=new DataTable();
dt.Columns.Add("Score",typeof(double));
dt.Columns.Add("Name",typeof(string));
DataRow dr;
foreach(DataRow drow in ds.Tables[0].Rows)
{
dr = dt.NewRow();
dr["Score"] = drow ["intScore"];
dr["Name"]=drow ["strGameName"];
dt.Rows.Add(dr);
}
DataView dv=dt.DefaultView;
dv.Sort="Score desc";
DataGrid drg=new DataGrid();
drg.DataSource=dv; //drg is DataGrid
drg.DataBind();
this.Controls.Add(drg);
}

...S.VinothkumaR

Double Formatting.

Here is sample for double formatting by using C#.

Double dblScore = 2.0;
string str = dblScore.ToString("#,##0.0;(#,##0.0);00.0");

...S.Vinothkumar.