Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   How to get gridview selected row text (http://www.velocityreviews.com/forums/t527539-how-to-get-gridview-selected-row-text.html)

Dinu 08-07-2007 12:56 PM

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


Brian 08-07-2007 01:15 PM

Re: How to get gridview selected row text
 
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" <visitdinu@gmail.com> wrote in message
news:1186491366.458797.323180@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
>




All times are GMT. The time now is 08:56 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.