Wednesday, July 20, 2011

Adding a new column to a table with the same data existing in other column of same data table with different datatype..

  //Data table creation DataTable dt = new DataTable();
for (int i = 0; i < 10; i++)
dt.Columns.Add("SNo", typeof(string));
{
DataRow dr = dt.NewRow();
dr["SNo"] = i.ToString();
}
//Adding new column saying serailNo with datatype as int
dt.Columns.Add("SerailNo", typeof(int), "Convert(SNo ,System.Int32)");
//Now you can see a new column saying serialno with datatype int32

Sunday, July 17, 2011

Adding S.No column to grid

<asp:TemplateField HeaderText="S.No"><ItemTemplate><%
#Container.DataItemIndexIndex + 1 %></ItemTemplate></asp:TemplateColumn>