I want to update only selected row, but entire rows were updated instead, like this:
Afterwards, I have tried using @SMT_Assembly for update statement but it give me error "Must declare the scalar variable". I'm new to ASP.net ,please make any necessary modification on my source code and your helps are much appreciated.
Homepage.aspx:
<asp:GridView ID="GridView1" DataKeyNames="SMT_Assembly" AutoGenerateColumns="false" runat="server" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="4" GridLines="Horizontal" Height="214px" Width="848px">
<asp:HyperLinkField DataTextField="IQA_status" NavigateUrl="ConfirmIQAstatus.aspx" HeaderText="IQA status"/>
<asp:HyperLinkField DataTextField="Overall_Status" NavigateUrl="ConfirmIQAstatus.aspx" HeaderText="Overall_Status"/>
</Columns>
</asp:GridView>
Homepage.cs
public partial class Homepage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection(@"Data Source=MYPENM0LSQLV01D\INST3;Initial Catalog=RTDF;Persist Security Info=True;User ID=*******; Password=*******");
String query = "UPDATE RTDF.dbo.SMT_CompWeight SET IQA_status = 'Open' where SMT_Assembly = @SMT_Assembly ";
SqlCommand retrieveCommand = new SqlCommand(query,sqlcon);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = retrieveCommand;
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
sqlcon.Close();
}
}