Solved

gridview selected row

Posted on 2006-11-20
7
6,664 Views
Last Modified: 2011-08-18
I am trying to get the id of the selected row in a gridview instead of the index

0
Comment
Question by:samme
7 Comments
 
LVL 17

Expert Comment

by:lem2802
Comment Utility
GridView1.DataKeys[GridView1.SelectedRow.Index];
0
 
LVL 1

Author Comment

by:samme
Comment Utility
I am using vb so i changed it to
GridView1.DataKeys(GridView1.SelectedRow.Index)

It gives me the error "index not a member of system....gridviewrow"
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 50 total points
Comment Utility
GridView1.DataKeys(GridView1.SelectedIndex)

Bob
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 28

Accepted Solution

by:
strickdd earned 75 total points
Comment Utility
I did my best to convert my C# to VB, but just in case I have both...

protected Sub GridView_RowCommand(object sender, GridViewCommandEventArgs e)

            'find out which row was clicked
            Dim rowIndex as Int = e.CommandArgument;

            dim DBID as Int = sender.DataKeys(rowIndex).Value;

End Sub

protected void CategoryDataGrid_RowCommand(object sender, GridViewCommandEventArgs e)
      {
            // find out which row was clicked
            int rowIndex = Utilities.CommonFunctions.ConvertToInt(e.CommandArgument);

            String DBID = Utilities.CommonFunctions.ConvertToString(((GridView)sender).DataKeys[rowIndex].Value);
      }
0
 
LVL 4

Expert Comment

by:satish_nagdev
Comment Utility
hi,
could you try this
    protected void gv1_SelectedIndexChanged(object sender, GridViewSelectEventArgs e)
    {
        int indx = e.NewSelectedIndex;
       //then you can access new selected row & its cells using
       //gv1.Rows[indx].Cells
    }

regards,
satish.
0
 
LVL 1

Author Comment

by:samme
Comment Utility
Ended up with this result
Dim selectedRecord As DataKey = GridView1.DataKeys(GridView1.SelectedIndex)
Dim idValue As String = selectedRecord.Value
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
And, does that work as expected?

Bob
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now