To show modifications/updations in the grid normally we will update in the table and then bind that table to grid. This is easy insted of doing on grid. why bcoz if we bind our grid with table/dataset once again the modifications which are doing on grid will be lost. Grid will freshly rebind the rows and columns which are in table/dataset. if we are doing on grid directly we need to find the exact control and need to update that one.
I dont know in which process you r doing. So i have given like that.i think its better to add item template with lable control to your grid as bellow
- <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="111px"
-
OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
-
<Columns>
-
<asp:CommandField ButtonType="Button" ShowSelectButton="True" />
-
-
<asp:TemplateField HeaderText="time label">
-
<ItemTemplate>
-
<asp:Label ID="lbltime" runat="server" />
-
</ItemTemplate>
-
</asp:TemplateField>
on selected index change of grid find that control and update that control as bellow . Dont bind grid again with table/dataset. Bcoz it will lose the data.
- protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
-
{
-
Label lblTime = ((Label)GridView1.Rows[GridView1.SelectedIndex].Cells[1].FindControl("lbltime"));
-
//Here Cells[1] is 2nd column "time label"
-
lblTime.Text = DateTime.Now.ToString();
-
}