Hi all!
How can i update the values in textboxes from gridview using ID(Primary Key).
Below is my gridview code..
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" SelectedRowStyle-BackColor="#ccff99" AutoGenerateSelectButton="True">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="EmpID" HeaderText ="ID" />
<asp:BoundField dataField="FirstN" HeaderText="FirstN" />
<asp:BoundField DataField="LastN" HeaderText="LastN" />
<asp:BoundField DataField="Gender" HeaderText="Gender" />
<asp:BoundField DataField="Address" HeaderText="Address" />
<asp:BoundField DataField="Salary" HeaderText="Salary" />
<asp:BoundField DataField="Jdate" HeaderText="Jdate" />
</Columns>
here is my update query--
SqlCommand cmd1 = new SqlCommand("Update tblCRUD set values FirstN='" + TextBox1.Text + "',LastN='" + TextBox2.Text + "',Gender='" + gender + "',Address='" + TextBox3.Text + "',Salary='" + TextBox4.Text + "',Jdate='" + TextBox5.Text + "' where EmpID=?, con1");
cmd1.CommandType = CommandType.Text;
if (con1.State == ConnectionState.Closed)
{
con1.Open();
cmd1.ExecuteNonQuery();
clear();
}
how to pass the EmpID value?
Thanks..