473,474 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

rowselect in gridview

Hi everyone

I am tryin to get the selected index from this gridview while selecting the
radiobuttonlist. I dont want to use a button for the row though. Anyone
knows how to do this?

thnks

Eric
<%@ Page Language="VB" %>

<script runat="server">
Protected Sub rbl_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim index As Integer

End Sub

</script>

<html>

<body>

<form id="form1" runat="server">

<table width="100%">

<tr>

<td style="width: 50%">

<asp:GridView ID="CustomersGridView" DataSourceID="CustomersSource"
AllowPaging="true"

AutoGenerateColumns="false" runat="server">

<Columns>

<asp:BoundField DataField="CustomerID" HeaderText="Customer ID" />

<asp:BoundField DataField="CompanyName" HeaderText="Company Name" />

<asp:BoundField DataField="City" HeaderText="City" />

<asp:TemplateField>

<ItemTemplate>

<asp:RadioButtonList ID="rbl" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="rbl_SelectedIndexChanged">

<asp:ListItem>

one

</asp:ListItem>

<asp:ListItem>two</asp:ListItem>

</asp:RadioButtonList>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

</td>

<td style="vertical-align: top; width: 51%">

</td>

</tr>

</table>

<asp:SqlDataSource ID="CustomersSource" SelectCommand="select * From
Customers"

connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server" />

</form>

</body>

</html>
Jan 11 '07 #1
1 1711
If I understand you correctly, you need to find the index of the row with
the selected radiobutton.

The rbl_SelectedIndexChanged event handler gets a reference to the
radiobutton that initiated the event. You can navigate to the datagrid row
that contains the button via the Parent property. Set a breakpoint and see
in the debugger how many times you need to call Parent to get from the
radiobutton to the row. Once you have the row, its RowIndex property will
tell you the index.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Eric Effer" <be****@gmail.comwrote in message
news:ul**************@TK2MSFTNGP06.phx.gbl...
Hi everyone

I am tryin to get the selected index from this gridview while selecting
the radiobuttonlist. I dont want to use a button for the row though.
Anyone knows how to do this?

thnks

Eric
<%@ Page Language="VB" %>

<script runat="server">
Protected Sub rbl_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim index As Integer

End Sub

</script>

<html>

<body>

<form id="form1" runat="server">

<table width="100%">

<tr>

<td style="width: 50%">

<asp:GridView ID="CustomersGridView" DataSourceID="CustomersSource"
AllowPaging="true"

AutoGenerateColumns="false" runat="server">

<Columns>

<asp:BoundField DataField="CustomerID" HeaderText="Customer ID" />

<asp:BoundField DataField="CompanyName" HeaderText="Company Name" />

<asp:BoundField DataField="City" HeaderText="City" />

<asp:TemplateField>

<ItemTemplate>

<asp:RadioButtonList ID="rbl" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="rbl_SelectedIndexChanged">

<asp:ListItem>

one

</asp:ListItem>

<asp:ListItem>two</asp:ListItem>

</asp:RadioButtonList>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

</td>

<td style="vertical-align: top; width: 51%">

</td>

</tr>

</table>

<asp:SqlDataSource ID="CustomersSource" SelectCommand="select * From
Customers"

connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server" />

</form>

</body>

</html>


Jan 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
6
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
6
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the...
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.