473,382 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to get gridview selected row text

hi

i am having a gridview in aspx page and a usercontrol in master page
of that page

now what i want is selected row text to be displayed in usercontrol

i wrote code as follows:

Protected Sub gvwServices_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles gvwServices.SelectedIndexChanged
Me.Master.SetStatusText =
gvwServices.SelectedRow.Cells(0).Text
End Sub

here setstatus is the property of master page thats sets selected row
text to usercontrol

please help me in this regard

Thanks

Aug 7 '07 #1
1 5022
I'm not quite sure if this is what you are after but:

internal void Grid_ViewCommand(Object sender, DataGridCommandEventArgs e)
{
TableCell itemCell = e.Item.Cells[1];
string item = itemCell.Text;
}

With a Grid, I typically put a button as the first column - called "View".
Clicking this button fires this event where I can retrieve the second cell
of the row (the first cell contains the button) that was selected and then
extract the text from. I suspect you need this same thing but on the
Index_Change event...

My Grid definition looks like this:
<asp:DataGrid ID="dataGrid1" runat="server" DataSourceID="XmlDataSource1"
Width="274px" AutoGenerateColumns="False" OnItemCommand="Grid_ViewCommand" >
<HeaderStyle BackColor="#00AAAA">
</HeaderStyle>
<Columns>
<asp:ButtonColumn
HeaderText="View"
ButtonType="PushButton"
Text="View"
CommandName="ViewItem" />

<asp:BoundColumn
HeaderText="Category Name"
DataField="name"/>
</Columns>
</asp:DataGrid>
-brian
"Dinu" <vi*******@gmail.comwrote in message
news:11**********************@g12g2000prg.googlegr oups.com...
hi

i am having a gridview in aspx page and a usercontrol in master page
of that page

now what i want is selected row text to be displayed in usercontrol

i wrote code as follows:

Protected Sub gvwServices_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles gvwServices.SelectedIndexChanged
Me.Master.SetStatusText =
gvwServices.SelectedRow.Cells(0).Text
End Sub

here setstatus is the property of master page thats sets selected row
text to usercontrol

please help me in this regard

Thanks
Aug 7 '07 #2

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

Similar topics

1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
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...
0
by: Aws | last post by:
My crazy GridView !! I am using Visual Studio 2005, I have a problem with my GridView. I have one access .mdb table and when I update a record on the table EVERYTHING is perfect. I made a Web...
1
by: CorporateCoder | last post by:
Hi, I am trying to bind the selected value of a databound dropdown box in a databound gridview control to the value being displayed in the template column the dropdown box has been added to. ...
2
by: Loading name... | last post by:
Hey asp.net 2.0 I have a GridView on my webpage. This GridView's datasource is a SqlDataSource. The SqlDataSource returns 3 columns. Here is my problem: My GridView consist of 3 columns...
4
by: Randy Smith | last post by:
Hi, I would like to limit my user selection to only one row in the GridView at a time. Is there any way to set this? TIA, Randy
1
by: RGF | last post by:
I have a GridView control which is binded to a dataset object, I am able to populate the GridView with the expected data, so that is ok. I enabled the Selection function from the GridView, which...
1
by: l3d007 | last post by:
I used this example straight from msdn in a gridview that already sorts based on each column. For some reason I cannot get it to sort based on two sorting expressions.Is there some property of the...
2
by: bogdan | last post by:
Hi, Can a single GridView be 'connected' to DetailsView that renders itself differently based on the currently selected row? I have a GridView with rows that could be displayed in the same way...
25
by: premprakashbhati | last post by:
i want to have checkboxes in my gridview ...by checking it ,i can delete the row/rows.... so i have written code and got 2 Errors ...can anyone solve it... Error:1...'gridview.RetrieveItems()': not...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.