Help Please!

S

Shahid Juma

Hi,

I am new to ASP.NET and I am having a hard time figuring out
somethings.

I have an XML file which I read thru and create a form using the
Page_Load. In the form, I have radio buttons which I also create
dynamically. This is done in the actual code not the script.

Now, when i want to save it, I need to access the elements of the radio
buttons. How do I do this? On the on_click event of the button which I
put on the form grid, it complaints that the radio button doesn't
exist.

Any help would be greatly appreciated.

Shahid
 
D

darrel

I have an XML file which I read thru and create a form using the
Page_Load. In the form, I have radio buttons which I also create
dynamically. This is done in the actual code not the script.

Not sure what the difference is between the code and the script.
Now, when i want to save it

Save what? The value of the radio buttons?
On the on_click event of the button which I
put on the form grid, it complaints that the radio button doesn't
exist.

Are your radio buttons set to runat="server"? If not, you need to add that
in there so the codebehind can 'see' them.

-Darrel
 
C

Craig Deelsnyder

Shahid said:
Hi,

I am new to ASP.NET and I am having a hard time figuring out
somethings.

I have an XML file which I read thru and create a form using the
Page_Load. In the form, I have radio buttons which I also create
dynamically. This is done in the actual code not the script.

Now, when i want to save it, I need to access the elements of the radio
buttons. How do I do this? On the on_click event of the button which I
put on the form grid, it complaints that the radio button doesn't
exist.

Any help would be greatly appreciated.

Shahid

You have to be sure to add the controls on each postback as well. That
way asp.net can map them up to the incoming request/postback. An
in-depth discussion here:

http://aspnet.4guysfromrolla.com/articles/092904-1.aspx
 
S

Shahid Juma

This is snippet of how my code is: (in page_load, i call a function
which I created)

.....
while (reader.Read()) {
sb.Append("\t<tr bgColor=\"" + rowColour + "\">\n");
sb.Append("\t\t<td>&nbsp;</td>\n");
sb.Append("\t\t<td>" + detailedQuestion + number.ToString() +
"</td>\n");
sb.Append("\t\t<td>Y <input runat=\"server\" id=\"score_" +
number.ToString() + "_" + subNumber.ToString() + "\" type=\"radio\"
class=\"box2\" name=\"score_" + number.ToString() + "_" +
subNumber.ToString() + "\" value=\"Y\">");
sb.Append(" N <input runat=\"server\" id=\"score_" + number.ToString()
+ "_" + subNumber.ToString() + "\" type=\"radio\" class=\"box2\"
name=\"score_" + number.ToString() + "_" + subNumber.ToString() + "\"
value=\"N\">");
sb.Append(" N/A <input runat=\"server\" id=\"score_" +
number.ToString() + "_" + subNumber.ToString() + "\" type=\"radio\"
class=\"box2\" name=\"score_" + number.ToString() + "_" +
subNumber.ToString() + "\" value=\"NA\" checked></td>\n");
sb.Append("\t\t<td> <div align=\"center\">");
sb.Append(" " + theValue.ToString() + "</div></td>\n");
sb.Append("\t</tr>\n");
.....
....
}
lblformValues.Text = sb.ToString();

On the form designer, I have a button which when clicked on is where I
want to extract the above values which as can be seen are dynamically
created.

Thanks,
Shahid
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top