J
John Holmes
I'm using data to rename some web controls on a form that uses a repeater
contol and so it can have mulitple instances of the same control set. The
controls get renamed (thanks to Steven Cheng's help) in a click event of the
button that is pushed to enter data. Each time the button is clicked it
sends the ID entered by the user to query the database and return
information. The renamed controls then include the ID in the name of the
control.
At the bottom of my html form, Form1, is a button used to update the dataset
with any information entered in by the user. I need to access the renamed
controls at this point and check their values, and I can build a string that
is the same as the ID of the control. I'm not sure how to use this string to
access say the Checked value of a CheckBox, though. I've tried various
things, but I don't think I have the scope correct and could use some tips.
private void btnSubmitForm_ServerClick(object sender, System.EventArgs e)
{
foreach(DataRow row in dsAssessorData.Tables["tabParcels"].Rows)
{
string strParcelID = row["ParcelID"].ToString();
CheckBox chkHist = (CheckBox)Form1.FindControl("chk" + strParcelID +
"Historic");
row["Historic"] = chkHist.Checked;
}
}
Gives the following error:
C:\Inetpub\wwwroot\Affidavits\WebForm1.aspx.cs(407): The type or namespace
name 'Form1' could not be found (are you missing a using directive or an
assembly reference?)
contol and so it can have mulitple instances of the same control set. The
controls get renamed (thanks to Steven Cheng's help) in a click event of the
button that is pushed to enter data. Each time the button is clicked it
sends the ID entered by the user to query the database and return
information. The renamed controls then include the ID in the name of the
control.
At the bottom of my html form, Form1, is a button used to update the dataset
with any information entered in by the user. I need to access the renamed
controls at this point and check their values, and I can build a string that
is the same as the ID of the control. I'm not sure how to use this string to
access say the Checked value of a CheckBox, though. I've tried various
things, but I don't think I have the scope correct and could use some tips.
private void btnSubmitForm_ServerClick(object sender, System.EventArgs e)
{
foreach(DataRow row in dsAssessorData.Tables["tabParcels"].Rows)
{
string strParcelID = row["ParcelID"].ToString();
CheckBox chkHist = (CheckBox)Form1.FindControl("chk" + strParcelID +
"Historic");
row["Historic"] = chkHist.Checked;
}
}
Gives the following error:
C:\Inetpub\wwwroot\Affidavits\WebForm1.aspx.cs(407): The type or namespace
name 'Form1' could not be found (are you missing a using directive or an
assembly reference?)