473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting SelectedIndex of DropDownList in GridView

Getting the SelectedIndex of a DropDownlist under the ItemTemplate in a
GridView is harder than I thought it would be.

I have:

A Gridview of n rows bound to a DataSet.
A DropDownList as an ItemTemplate in the GridView populated with three
ListItems.
A Button to Submit the form.

The desired outcome is for the user to make selections in the
dynamically generated DropDownLists in the rows fo the GridView and
submit the form.
Based on the SelectedIndex values of the DropDownLists the appopriate
code will be executed.

Unfortunately, the user can select an item from the DropDownList in
each row, but there is no SelectedIndexChanged event associated with
the dynmaically created DropDownLists, although the event is defined in
the tag and exists in the codebehind for the control named under the
ItemTemplate.

The DropDownlists are not in the ViewState, although the ViewState
property on the control named under the ItemTemplate is enabled.

I would like to find a way includ the SelectedIndex values of the
DropDownLists when the form is submitted.
If this can't be done directly, I'd like to find a way to hook up an
event to the DropDownLists so I can use the FindControl to return the
SelectedIndex and write it to an elemnt in the form.
I've gone through numerous approaches from Delegates to Event
Bubbling, after reading countless recommendations.

I could achieve my objective using client-side scripting, but am trying
to do things the .Net way now.

Any help would be appreciated.

Thanks

Dan

Sep 8 '06 #1
0 2343

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
3
by: Nathan Sokalski | last post by:
I am working on a simple user control composed of 3 DropDownLists that will be used to select Dates. The purpose of the control is to all the user to choose a date using dropdown lists but not need...
5
by: Nathan Sokalski | last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an...
1
by: Nathan Sokalski | last post by:
I have a problem that is driving me crazy. I have a User Control composed of three DropDownLists that will be used to select a date. I have everything working except for one thing. When I select a...
6
by: Nathan Sokalski | last post by:
I am writing a User Control that uses 3 DropDownLists. When I attempt to access the SelectedIndex property it incorrectly reports the value selected by the user. Why is this? Here is my code,...
0
by: keithb | last post by:
With a DropDownList in a GridView Edit Template, how can I set the SelectedIndex property so that the list initializes to the value shown in the Display template? When I set SelectedIndex to -1,...
0
by: Mike P | last post by:
How do you get access to the values you have entered under edit mode in a gridview? I only seem to be able to access the values prior to them being edited. protected void...
1
by: marcbb | last post by:
Hi all, I have a really strange problem working with Dropdownlists in a DataGrid. I'm trying to preselect some values from the DropDownlist for each row in the DataGrid, but it seems that...
0
by: baburk | last post by:
I am having dropdownlist inside gridview. When the dropdownlist selectedindex change an event should fire. What is the event for his. I also want to get the dropdownlist event fired row...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.