c# - Radio Buttons in Gridvew -


i have list of games. each game has visiting team , home team. allow user choose either visiting team or home team. converted template fields , put radio buttons in. isnt right. need radio button list, think. because radio buttons, can select both. possible gridview? tutorials see have 1 radio button in row, isnt issue. here gridview:

<asp:gridview id="gridview2" runat="server" autogeneratecolumns="false" datakeynames="id_game" datasourceid="sqlpopulategames">         <columns>             <asp:boundfield datafield="id_game" headertext="id_game" insertvisible="false" readonly="true" sortexpression="id_game" />             <asp:templatefield headertext="visitor" sortexpression="visitor">                 <edititemtemplate>                     <asp:textbox id="textbox1" runat="server" text='<%# bind("visitor") %>'></asp:textbox>                 </edititemtemplate>                 <itemtemplate>                     <br />                     <asp:radiobutton id="radiobutton1" runat="server" text='<%# eval("visitor") %>' />                 </itemtemplate>             </asp:templatefield>             <asp:templatefield headertext="home" sortexpression="home">                 <edititemtemplate>                     <asp:textbox id="textbox2" runat="server" text='<%# bind("home") %>'></asp:textbox>                 </edititemtemplate>                 <itemtemplate>                     <asp:radiobutton id="radiobutton2" runat="server" text='<%# eval("home") %>' />                 </itemtemplate>             </asp:templatefield>             <asp:boundfield datafield="game_time" headertext="game_time" sortexpression="game_time" />         </columns>     </asp:gridview> 

because radio buttons, can select both.

not if radio buttons grouped in markup. radio buttons designed mutually-exclusive, need know other radio buttons exclusive with. the groupname property in asp.net used set this.

something this:

<asp:radiobutton groupname="somegroup" id="radiobutton1" runat="server" text='<%# eval("visitor") %>' /> 

with set, mutually exclusive other radiobutton groupname set "somegroup".

since happening inside repeated control, want separate group each iteration. can bind value in backing data:

<asp:radiobutton groupname='<%# eval("somevalue") %>' id="radiobutton1" runat="server" text='<%# eval("visitor") %>' /> 

if somevalue unique each record in result, end grouped pair of mutually exclusive radio buttons each row.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -