473,466 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Filter data of a dropdownlist in datagrid

I have a datagrid with two temnplate columns. When a row is in edit mode the
each template columns show a dropdownlist (its datasource is a dataview).

I need to filter data of second dropdownlist when the user select an item of
first dropdownlist.

I have the event OnSelectedIndexChanged of first dropdownlist. I try to use
de rowfilter property of dataview with no exit.

Is posible to do this? How?
Nov 19 '05 #1
3 1941
1- while handling the OnSelectedIndexChanged of the first dropdownlist get a
reference to the NamingContainer (the selected datagriditem)
2- use FindControl within the selected datagriditem to get a reference to
the second dropdownlist
3- filter the dataview and rebind to the dropdownlist.

I have an example that can help you with steps 1-2
http://www.societopia.net/Samples/Da...olsEvents.aspx and then
you can figure step3 easily.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Juanjo" wrote:
I have a datagrid with two temnplate columns. When a row is in edit mode the
each template columns show a dropdownlist (its datasource is a dataview).

I need to filter data of second dropdownlist when the user select an item of
first dropdownlist.

I have the event OnSelectedIndexChanged of first dropdownlist. I try to use
de rowfilter property of dataview with no exit.

Is posible to do this? How?

Nov 19 '05 #2
OK Phillip, many many thanks.

Now my 2 dropdownlists works ok, but now my problem is with the second
dropdownlist and the property selectedvalue.

I need to set this property, I try with
CType(dgEquiArt.Items(dgEquiArt.EditItemIndex).Cel ls(7).Controls(1),
DropDownList).SelectedValue="XXXXX"

in event OnSelectedIndexChanged of first dropdownlist, but causes an error

El argumento especificado está fuera del intervalo de valores válidos.
Nombre del parámetro: 4730601

In english: The argument specified is out of valid interval values.
Parameter name 4730601

Could you help me?
Nov 19 '05 #3
Hi Juanjo,

For easier debugging during development I recommend that you expand that one
line of code to be like this:

Dim ddl As DropDownList
Dim dgi As DataGridItem
dgi = CType(dgEquiArt.Items(dgEquiArt.EditItemIndex), DataGridItem)
'or if you are writing this in the method that handles the
DataGrid.EditCommand
'event use the datagrid item from the passed parameter of type
'DataGridCommandEventArgs like this:
'dgi = e.Item
ddl = dgi.FindControl("SecondDropDownListID") 'use here the ID of the
dropdownlist
If ddl Is Nothing Then
Throw New Exception("Could not find the second dropdwonlist")
Else
ddl.ClearSelection()
Dim oListItem As ListItem = ddl.Items.FindByValue("xxxx")
If Not oListItem Is Nothing Then oListItem.Selected = True
End If

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Juanjo" wrote:
OK Phillip, many many thanks.

Now my 2 dropdownlists works ok, but now my problem is with the second
dropdownlist and the property selectedvalue.

I need to set this property, I try with
CType(dgEquiArt.Items(dgEquiArt.EditItemIndex).Cel ls(7).Controls(1),
DropDownList).SelectedValue="XXXXX"

in event OnSelectedIndexChanged of first dropdownlist, but causes an error

El argumento especificado está fuera del intervalo de valores válidos.
Nombre del parámetro: 4730601

In english: The argument specified is out of valid interval values.
Parameter name 4730601

Could you help me?

Nov 19 '05 #4

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

Similar topics

2
by: sunstarwu | last post by:
Hi, I am having difficultly being able to view certain Columns and rows via a DropDownList. Everytime I load my webpage.aspx it just shows empty drop down menus. I have no problem showing all...
2
by: Brian Henry | last post by:
Hi, I have a data grid that is set up like this Page items displayed = 10 EnableViewState = false (i dont want to send large amounts of data over the internet!) CustomPaging = false...
1
by: Moshfegh Hamedani | last post by:
Hi there, I found this question in Amit Kalani's preparation book for exam 70-15 (Developing Web Applications with C#). I think it's a very stupid question! It says the correct answer is A but...
0
by: Moshfegh Hamedani | last post by:
Hi there, I found this question in Amit Kalani's preparation book for exam 70-15 (Developing Web Applications with C#). I think it's a very stupid question! It says the correct answer is A but...
0
by: RyanG | last post by:
when the value that determines the filter is databound?? I am trying to make a DropDownList for a set of data that I use a lot throughout my project. So I extended the DropDownList to retrieve...
0
by: Juanjo | last post by:
Hi, Before, I was working with Asp.net 1.0 and datagrid. I posted a question for this issue. The solution of this problem is load the second dropdownlist on the selectedindexchanged event of the...
6
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
8
by: Cirene | last post by:
I have a dropdownlist that is bound to a query. Is it possible to further filter the items after the fact? The dropdownlist is inside a...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.