Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read From Radiobutton Group in a Datagrid

Status
Not open for further replies.

B827

Technical User
Feb 14, 2002
281
GB
Hi,
I have a problem which I am sure will be easy to solve but I just cant see the solution.

I have a small questionnaire in an ASP.NET application which consists of 5 questions with a radio button group of 4 mutually exclusive answers which I want to store in a database. Currently everything works and the radio buttons are in template columns. But I cannot work out how to retrieve the selected values once the form is posted back.

Could some one give me an example of the code used to do this please?

Sandy
 
Thanks for looking Ca8msm, the code for the datagrid is:

<asp:datagrid id=DataGrid1 runat="server" Width="256px" AutoGenerateColumns="False" DataKeyField="ID" DataMember="SOURCE_DATA" DataSource="<%# DsRealThing1 %>">
<Columns>
<asp:BoundColumn DataField="ID" SortExpression="ID" HeaderText="ID Number"></asp:BoundColumn>
<asp:BoundColumn DataField="COUNTRY" SortExpression="COUNTRY" HeaderText="Country"></asp:BoundColumn>
<asp:BoundColumn DataField="ORGANISATION" SortExpression="ORGANISATION" HeaderText="Organisation"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Option A">
<ItemTemplate>
<asp:RadioButton id="Radio_a" runat="server" GroupName="Optionsel"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Option B">
<ItemTemplate>
<asp:RadioButton id="Radio_b" runat="server" GroupName="Optionsel"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Option C">
<ItemTemplate>
<asp:RadioButton id="Radio_c" runat="server" GroupName="Optionsel"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Option D">
<ItemTemplate>
<asp:RadioButton id="Radio_d" runat="server" GroupName="Optionsel"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

Sandy
 
OK, if you need to get a reference to a control within a DataGrid's TemplateColumn, you'll have to use the FindControl method.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top