Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to get gridview selected row text

Reply
Thread Tools

How to get gridview selected row text

 
 
Dinu
Guest
Posts: n/a
 
      08-07-2007
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

 
Reply With Quote
 
 
 
 
Brian
Guest
Posts: n/a
 
      08-07-2007
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:
<aspataGrid 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>
</aspataGrid>


-brian
"Dinu" <> wrote in message
news: 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
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Want to add row under selected row of gridview ujjc001@gmail.com ASP .Net Building Controls 1 02-16-2007 07:14 PM
Selected Row Only GridView Row Visible? needin4mation@gmail.com ASP .Net Web Controls 0 10-17-2006 10:07 PM
Gridview row databound event - can't get past the 1st row of gridview maurban@gmail.com ASP .Net 5 10-13-2006 09:37 PM
GridView nested in DataList - refreshing corresponding DataList row after updating GridView row H5N1 ASP .Net 0 04-26-2006 11:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57