Solved

Capturing the selected index of a dropdown in the gridview

Posted on 2013-01-26
1
610 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

18 Experts available now in Live!

Get 1:1 Help Now