Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Filter data of a dropdownlist in datagrid

Reply
Thread Tools

Filter data of a dropdownlist in datagrid

 
 
=?Utf-8?B?SnVhbmpv?=
Guest
Posts: n/a
 
      11-09-2005
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?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      11-09-2005
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?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SnVhbmpv?=
Guest
Posts: n/a
 
      11-10-2005
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?


 
Reply With Quote
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      11-10-2005
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?
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How filter dropdownlist data Cirene ASP .Net 8 05-28-2008 08:09 PM
GridView: Filter DropDownList for another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-29-2005 07:44 AM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM
How can you filter data in a Custom DropDownList.... RyanG ASP .Net 0 08-23-2004 03:27 PM
UV Protector filter vs. Skylight filter? john Digital Photography 8 06-26-2004 03:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57