Posts

Showing posts from October, 2011

Tips

If you Select the Datagrid and need the data of the selected Datakey 1) Convert.ToInt32(Datagrid.SelectedDataKeys[0].Tostring()); 2) Convert.ToInt32(Datagrid.SelectedDataKeys["Datafield Name"].Tostring()); If Datakey is given to Datagrid and not Selected Convert.ToInt32(Datagrid.DataKeys[0][“Column name”].Tostring()); If Columns are given to Datagrid  Datagrid.Rows[0].Cells[3].Text; Check if Column Name is Result If (Dataset.Tables[0].Columns[0].ColumnName==”Result”); Count No of Tables in Dataset Dataset.Tables.Count==2 Count No of Rows in a table of Dataset Dataset.Tables[0].Rows.Count Count No of Rows in a Datagrid Datagrid.Rows.Count Get the value of Dataset Dataset.Tables[0].Rows[0]["Datafield Name"].Tostring(); .Add the below code in the html where you want to output the year <%=DateTime.Now.Year%>

To Create a Datatable in ViewState

protected void Page_Load(object sender, EventArgs e)         {             if (!IsPostBack)             {                 BindData();             }         } private void BindData()         {             DataTable dt = new DataTable();             dt.Columns.Add("Column name");             dt.Columns.Add("colum 2");             dt.Columns.Add("colum 3");           ...