<asp:GridView ID="sview" runat="server" SelectedIndex="0" OnRowDataBound ="Table_DataBound" style="font-family: Verdana; font-size: X-Small; font-weight: bold; top: 13px; left: 1px; position: absolute; height: 20px; width: 646px; border: 1px Solid Black" OnRowEditing ="Table_Edit" OnRowUpdating ="Table_Update" OnRowCancelingEdit ="Table_Cancel"> <columns> <asp:TemplateField HeaderText="subname" HeaderStyle-HorizontalAlign ="Left" > <edititemtemplate> <asp:TextBox ID="txtsubname" runat="server" Text='<%# Bind("subname") %>'> </edititemtemplate> <footertemplate> <asp:TextBox ID="txtNewName" runat="server" > </footertemplate> <itemtemplate> <%# Eval("subname") %> </itemtemplate> <asp:TemplateField HeaderText="sname" HeaderStyle-HorizontalAlign="Left"> <edititemtemplate> <asp:DropDownList ID="cmbgname" runat="server" DataTextField="Typename" DataValueField="Id"> </edititemtemplate> <itemtemplate> <%# Eval("gname") %> </itemtemplate> <footertemplate> <asp:DropDownList ID="cmbgname" runat="server" DataTextField="Typename" DataValueField="Id"> </footertemplate> <asp:CommandField SelectText="" ShowSelectButton="True" /> <asp:CommandField CancelText="" EditText="" ShowEditButton="True" UpdateText="" /> </columns> <SelectedRowStyle BackColor="#5691FE" /> <HeaderStyle BackColor="#D6BBBA" HorizontalAlign="Left" />
protected void Table_Edit(object sender, object e) { GridViewEditEventArgs ex = new GridViewEditEventArgs(sview.SelectedIndex); sview.EditIndex = ex.NewEditIndex; BindData(); } protected void Table_Update(object sender, object e) { DataTable dt = (DataTable)Session["ATable"]; GridViewRow row = sview.Rows[sview.EditIndex]; if (row.Cells[6].Text.Equals("Y")) { dt.Rows[row.DataItemIndex]["subname"] = ((TextBox)(row.Cells[2].FindControl (""))).Text; dt.Rows[row.DataItemIndex]["gname"] = ((DropDownList)(row.Cells[4].FindControl(""))).SelectedValue; } sview.EditIndex = -1; DataBind(); } protected void Table_Cancel(object sender, object e) { sview.EditIndex = -1; DataBind(); }
enableEventValidation
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)