I have a GridView with 2 columns, one a CheckBox and one a RadioButton.
But I have to do everything twice, one for each.
For example, I have the following:
For the CheckBox:
For the RadioButton:
The code is the same except for object type.
Is there a simpler way to consolidate the code?
Thanks,
Tom
But I have to do everything twice, one for each.
For example, I have the following:
For the CheckBox:
Code:
public void SelectGridViewCB(GridView oGrid, string rbName, int answerBits)
{
CheckBox cb = default(CheckBox);
int iKtr = 0;
//deselect all radiobutton in gridview
foreach (GridViewRow gvr in oGrid.Rows)
{
cb = (CheckBox)oGrid.Rows[iKtr].FindControl(rbName);
if (BitIsSet(answerBits, iKtr))
cb.Checked = true;
iKtr += 1;
}
}
For the RadioButton:
Code:
public void SelectGridViewRB(GridView oGrid, string rbName, int answerBits, object selection)
{
int iKtr = 0;
//deselect all radiobutton in gridview
foreach (GridViewRow gvr in oGrid.Rows)
{
RadioButton rb = default(RadioButton);
rb = (RadioButton)oGrid.Rows[iKtr].FindControl(rbName);
if(BitIsSet(answerBits,iKtr))
rb.Checked = true;
iKtr += 1;
}
}
The code is the same except for object type.
Is there a simpler way to consolidate the code?
Thanks,
Tom