DataGrid / Mutually Exclusive

G

g2

To my understanding it is not possible to have mutually exclusive radio
button controls in a datagrid.
(http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q316495). I have
read that it is possible to just emit standard input radio tags in the
itemtemplate column and the radio buttons should be mutually exclusive. I
have tried the below but I still do not get mutually exclusive controls. Any
ideas? Thanks.

<asp:TemplateColumn>
<ItemTemplate>
<INPUT id="rbcust" type="radio" runat="server">
</ItemTemplate>
</asp:TemplateColumn>
 
S

Sonali.NET[MVP]

Try
<asp:DataGrid id="DataGrid1" AutoGenerateColumns="False" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="FirstName">
<ItemTemplate>
<input type="radio" name="optSelectedName" value=<%#DataBinder.Eval(Container.DataItem, "FirstName") %> onclick="javascript:txtFname.value = this.value;"><%#DataBinder.Eval(Container.DataItem, "FirstName") %>
<br>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 154px; POSITION: absolute; TOP: 103px" runat="server" Text="Button"></asp:Button>
<div style="VISIBILITY: hidden">
<asp:TextBox ID="txtFname" Runat="server" />
</div>

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Dim myconnection As SqlConnection = New SqlConnection("server=localhost;uid=sa;password=;database=northwind")

Dim myda As SqlDataAdapter = New SqlDataAdapter("Select * from Employees", myconnection)

Dim ds As DataSet = New DataSet()

myda.Fill(ds, "AllTables")

DataGrid1.DataSource = ds

DataGrid1.DataBind()

End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Response.Write ("You have selected :" & txtFname.Text)

End Sub


HTH
Regards
Sushila
..NET MVP
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top