<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="624px" CssClass="grid" AllowPaging="True" AllowSorting="True" BackColor="White" OnRowEditing="GridView1_RowEditing" OnRowCancelingEdit="GridView1_RowCancelingEdit" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" PageSize = "5" OnRowUpdating="GridView1_RowUpdating" DataKeyNames="id"> <columns> <asp:TemplateField> <itemtemplate> <asp:CheckBox ID="chkchild" runat="server" AutoPostBack="true" /> </itemtemplate> <asp:TemplateField HeaderText="Username"> <edititemtemplate> <asp:TextBox ID="lbleditusr" runat="server" Text='<%#Eval("username") %>'/> </edititemtemplate> <itemtemplate> <asp:Label ID="lblitemUsr" runat="server" Text='<%#Eval("username") %>'/> </itemtemplate> <footertemplate> <asp:TextBox ID="txtftrusrname" runat="server"/> <asp:RequiredFieldValidator ID="rfvusername" runat="server" ControlToValidate="txtftrusrname" Text="*" ValidationGroup="validaiton"/> </footertemplate> <asp:TemplateField HeaderText="Password"> <edititemtemplate> <asp:TextBox ID="txtpass" runat="server" Text='<%#Eval("password") %>'/> </edititemtemplate> <itemtemplate> <asp:Label ID="lblpass" runat="server" Text='<%#Eval("password") %>'/> </itemtemplate> <footertemplate> <asp:TextBox ID="txtftrpass" runat="server"/> <asp:RequiredFieldValidator ID="rfvcity" runat="server" ControlToValidate="txtftrpass" Text="*" ValidationGroup="validaiton"/> </footertemplate> <asp:TemplateField HeaderText="Mail"> <edititemtemplate> <asp:TextBox ID="txtmail" runat="server" Text='<%#Eval("mail") %>'/> </edititemtemplate> <itemtemplate> <asp:Label ID="lblmail" runat="server" Text='<%#Eval("mail") %>'/> </itemtemplate> <footertemplate> <asp:TextBox ID="txtftrmail" runat="server"/> <asp:RequiredFieldValidator ID="rfvdesignation" runat="server" ControlToValidate="txtftrmail" Text="*" ValidationGroup="validaiton"/> </footertemplate> <asp:TemplateField> <edititemtemplate> <asp:ImageButton ID="imgbtnUpdate" CommandName="Update" runat="server" ImageUrl="~/gridviewimage/update.jpg" ToolTip="Update" Height="20px" Width="20px" /> <asp:ImageButton ID="imgbtnCancel" runat="server" CommandName="Cancel" ImageUrl="~/gridviewimage/Cancel.jpg" ToolTip="Cancel" Height="20px" Width="20px" /> </edititemtemplate> <itemtemplate> <asp:ImageButton ID="imgbtnEdit" CommandName="Edit" runat="server" ImageUrl="~/gridviewimage/Edit.jpg" ToolTip="Edit" Height="20px" Width="20px" /> <asp:ImageButton ID="imgbtnDelete" CommandName="Delete" Text="Edit" runat="server" ImageUrl="~/gridviewimage/delete.jpg" ToolTip="Delete" Height="20px" Width="20px" /> </itemtemplate> <footertemplate> <asp:ImageButton ID="imgbtnAdd" runat="server" ImageUrl="~/gridviewimage/AddNewitem.jpg" CommandName="AddNew" Width="30px" Height="30px" ToolTip="Add new User" ValidationGroup="validaiton" /> </footertemplate> </columns> <footerstyle backcolor="White" forecolor="#000066" /> <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /> <pagerstyle backcolor="White" forecolor="#000066" horizontalalign="Left" /> <rowstyle forecolor="#000066" /> <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /> <sortedascendingcellstyle backcolor="#F1F1F1" /> <sortedascendingheaderstyle backcolor="#007DBB" /> <sorteddescendingcellstyle backcolor="#CAC9C9" /> <sorteddescendingheaderstyle backcolor="#00547E" />
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; FillGrid(); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString()); TextBox lbleditusr = (TextBox)GridView1.Rows[e.RowIndex].FindControl("lbleditusr"); TextBox txtpass = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtpass"); TextBox txtmail = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtmail"); cmd = new SqlCommand("update getezee set username=@username,password=@password,mail=@mail where id=@id", con); cmd.Parameters.AddWithValue("@username", lbleditusr.Text); cmd.Parameters.AddWithValue("@password", txtpass.Text); cmd.Parameters.AddWithValue("@mail", txtmail.Text); cmd.Parameters.AddWithValue("@id", id); con.Open(); cmd.ExecuteNonQuery(); con.Close(); FillGrid(); }
cmd.Parameters.AddWithValue("@username", lbleditusr.Text);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)