Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

How to get gridview selected row text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dinu - 07 Aug 2007 13:56 GMT
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 - 07 Aug 2007 14:15 GMT
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
> hi
>
[quoted text clipped - 17 lines]
>
> Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.