I have a bit of a problem I was wondering if you could help me.
I have the following little bit of code:
protected void btnSubmit_Click(object sender, EventArgs e)
{
Page.Validate("RadMaterial");
Page.Validate("TopX");
int max = 0;
if (int.TryParse(txtbxHowMany.Text, out max))
{
GridView1.DataSource = this.GetMaterialData("123456",radTopx.SelectedItem.Value, "Primary", max);
GridView1.DataBind();
}
}
I have a couple of validation groups set up the first – if the click is made and the txtbxHowMany is not populated, a simple error is shown.
I also set up a validation group for the radiobutton list so that, should the user hit submit without checking a radiobutton, the required field validation should fire.
However, it is not firing. I am getting a “NullReferenceException was handled by user code.”
My thinking is that because the radTopx.SelectedItem.Value is, well, null.
How would I go about getting around this little issue of mine? Again, apologies for what is most likely a ridiculously easy question.
Interesting the way you used Validate method.
See what msdn says about it.
http://msdn.microsoft.com/en-us/library/dwzxc386.aspx