Selecting a value from a Gridview Control

H

hal

I'm trying to get a value from a gridview control and put that value in
a query string. I have a select button on the gridview and once the
user hits the select button i want to capture the the userid. Here's
some example code and you can see where i'm trying to do this in on the
line that starts with Response.Redirect:

protected void SearchUserMenu_MenuItemClick(object sender,
MenuEventArgs e)
{
if (GridView1.SelectedIndex > -1)
{
switch (e.Item.Text)
{
case "Security User":
Response.Redirect("~/SecurityUser.aspx?userID=" +
GridView1.SelectedRow.DataItem);
break;
case "WFM User Group/Location":
break;
case "Maintain User":
break;
case "Add User":
break;
}
}
}


any suggestions would be great.
Thanks
 
L

lwhitb1

Try this:

GridViewRow row = GridView1.SelectedRow;
string yourDataItem = row.Cells[1].Text;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,047
Members
48,769
Latest member
Clifft

Latest Threads

Top