Currently I have a Button Click event which takes the DataKey from a row in a Datagrid (via a checkbox) and assigns it to an INT variable to Update an Individual in a databsse. Everything works fine when I only check 1 checkbox and run the Update. However I need the User to have the option to select all checkboxes and take all those Datakeys and assign it to the same variable
INT oNewParentID
Like I said evrything works fine when only 1 checkbox is Selected. I guess I'm asking how to get an Uknoiwn amount of Datakeys or all DataKeys selected by all Checkboxes and store them in the Variable above to run the Update for all Individuals Selected. Here is my Button Click Event so far which is working for 1 checkbox selected:
protected void imgbtnReassgin_Click(object sender, ImageClickEventArgs e)
{
foreach (GridViewRow row in gvSalesmanCustomers.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("chkSalesCustSelector");
if (cb != null && cb.Checked)
{
int oIndividualID = Convert.ToInt32((gvSalesmanCustomers.DataKeys[row.RowIndex].Value));
foreach (GridViewRow r in gvSalesmanByManager.Rows)
{
CheckBox chkBox = (CheckBox)r.FindControl("chkManagerSalesSelector");
if (chkBox != null && chkBox.Checked)
{
int oNewParentID = Convert.ToInt32((gvSalesmanByManager.DataKeys[r.RowIndex].Value));
Individual ind = new Individual();
ind.ReassignIndividual(oIndividualID, oNewParentID);
chkBox.Checked = false;
cb.Checked = false;
}
}
}
}
}
And her is my Update Stored Procedure :
CREATE DEFINER=`root`@`%` PROCEDURE `reassign_Individual`(
IN oIndividualID int(11),
IN oNewParentID int(11)
)
BEGIN
Update intelliair.individual
set ParentID = oNewParentID
Where IndividualID = oIndividualID;END