Solved

Capturing the selected index of a dropdown in the gridview

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 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

19 Experts available now in Live!

Get 1:1 Help Now