Hi all I have a GridView (GridView1) I have added a column and insert a button:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="ObjectDataSource2"
onselectedindexchanged="GridView1_SelectedIndexChanged" Width="798px">
<Columns>
.....
<asp:ButtonField ButtonType="Button" CommandName="cmdFlag" Text="Flag" />
</Columns>
</asp:GridView>
Basically on click of the button I want to run a SQL Update but cant seem to click the button to enter C# and add the query. I can get in the C# for the page but unsure what to write for the method.
Heres the C# Code:
void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "cmdFlag")
{
con.Open();
cmd = new SqlCommand("UPDATE Comments SET Flagged = '" + "Yes" + "'", con);
cmd.ExecuteNonQuery();
}
}
Its doing nothing though. Basically I need it to look at the row and if the flagged button is clicked, update the comment to "Yes" under flagged.