Solved

Capturing the selected index of a dropdown in the gridview

Posted on 2013-01-26
1
616 Views
Last Modified: 2013-01-26
I have a dropdown inside of a gridview.  The user will select an item from the dropdown and click a link button (also inside the gridview).  

I am capturing the click event in the gridview's  RowCommand, but I also need to capture the value of the dropdown from the clicked row to pass to the next page.  

I tried this from the Rowcommand event, but I am getting an error.  

Dim ddl As DropDownList = TryCast(e.Row.FindControl("ddlCadence"), DropDownList)

Can someone help, please.

Thank you
0
Comment
Question by:sherbug1015
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
Element1910 earned 500 total points
ID: 38822522
What error are you getting??

You could try this in the meantime...add a OnSelectedIndexChanged event to your dropdownlist:
OnSelectedIndexChanged="ddlCadence_SelectedIndexChanged"

Open in new window

Then to capture the selected value:
Protected Sub ddlCadence_SelectedIndexChanged(sender As Object, e As EventArgs)
	Dim gv1 As GridViewRow = DirectCast(DirectCast(sender, Control).NamingContainer, GridViewRow)
	Dim ddl As DropDownList = DirectCast(gv1.FindControl("ddlCadence"), DropDownList)
	TextBox1.Text = ddl.SelectedItem.Value
End Sub

Open in new window

0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

695 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