<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="StudId" onrowcancelingedit="GridView1_RowCancelingEdit"
onrowupdating="GridView1_RowUpdating" >
<Columns>
<asp:BoundField DataField="StudId" HeaderText="ID" ReadOnly="true" ItemStyle-HorizontalAlign="Left" ItemStyle-Height="20" > /asp:BoundField>
<asp:BoundField DataField="StudName" HeaderText="StudName" ReadOnly="false" ItemStyle-HorizontalAlign="Left" ItemStyle-Height="20" >
/asp:BoundField>
<asp:CommandField ShowEditButton="true" />
/Columns>
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
DataControlFieldCell cell = GridView1.Rows[e.RowIndex].Cells[1] as DataControlFieldCell;
GridView1.Columns[1].ExtractValuesFromCell(e.NewValues, cell, DataControlRowState.Edit, true);
foreach (string key in e.NewValues.Keys)
{
Response.Write("
" + key + ": " + e.NewValues[key]);
}
}
0 comments:
Post a Comment