Hello Everyone,
I have a datagrid that pulls a query from the database, which consists of goals and each goal has an id # in the database.
So, the page displays something like this:
[checkbox] Goal1
[checkbox] Goal2
[checkbox] Goal3
And an "Update" button.
So, let's say I check Goal1 and Goal3 and then click on Update.. I need to be able to keep 'track of' the Goals using the checkboxes.
Right now, I have the datagrid populating fine with the goals and it displays a checkbox option by each one. My code needs to be able to recognize when an option is selected (or unselected), then go into the db and run a query.
Here's a function from the regular .aspx.cs page:
I haven't worked with checkboxes and I don't mean for the code to be confusing. First, I need to run a loop, something like 'while dgi exists, do { } '. Second, I'm not sure how to refer to a particular checkbox since... I've declared only one:
but it repeats for every goal (if that makes sense).
Any help will be appreciated. TIA.
I have a datagrid that pulls a query from the database, which consists of goals and each goal has an id # in the database.
So, the page displays something like this:
[checkbox] Goal1
[checkbox] Goal2
[checkbox] Goal3
And an "Update" button.
So, let's say I check Goal1 and Goal3 and then click on Update.. I need to be able to keep 'track of' the Goals using the checkboxes.
Right now, I have the datagrid populating fine with the goals and it displays a checkbox option by each one. My code needs to be able to recognize when an option is selected (or unselected), then go into the db and run a query.
Here's a function from the regular .aspx.cs page:
Code:
private void btnUpdate_Click(object sender, System.EventArgs e)
{
System.Web.UI.WebControls.CheckBox cb = (CheckBox)sender;
DataGrid dg = (DataGrid)cb.NamingContainer;
dgi.FindControl("cb"). ??
}
I haven't worked with checkboxes and I don't mean for the code to be confusing. First, I need to run a loop, something like 'while dgi exists, do { } '. Second, I'm not sure how to refer to a particular checkbox since... I've declared only one:
Code:
<ItemTemplate>
<asp:CheckBox id="cb" runat="server" OnCheckedChanged="Check_Clicked" ></asp:CheckBox>
</ItemTemplate>
Any help will be appreciated. TIA.