I need to add a line to choose a size into a dropdown . Since I have
the dropdown nested inside a datagrid this is not working.When a page
displays there are several rows of dropdowns but only the top dropdown
has the option added. The others do not.
I am using the following code
Dim ddlPsize As DropDownList
ddlPsize = (itemInfo.Items(0).FindControl("ddlsizes"))
ddlPsize.Items.Insert(0, "Choose a Size")
I obviously need to loop through the rows of the datagrid but I can
not seem to get it to work. I tried something like this
Dim i As Integer
Dim wRowsCount As Integer = itemInfo.Items.Count
Dim ddlPsize As DropDownList
For i = 0 To wRowsCount - 1
ddlPsize = (itemInfo.Items(0).FindControl("ddlsizes"))
ddlPsize.Items.Insert(0, "Choose a Size")
Next
But it did nothing
Ideas?
Thanks
LK
If you are with asp.net 2.0, you can set AppendDataBoundItems = true and add
the size item in the markup.
If you are with 1.1, move your loop to the PreRender event. You can also
insert ddl items for every datagrid item in the datagrid's ItemDataBound
event.

Signature
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
>I need to add a line to choose a size into a dropdown . Since I have
> the dropdown nested inside a datagrid this is not working.When a page
[quoted text clipped - 27 lines]
> Thanks
> LK
Me LK - 09 Oct 2007 18:07 GMT
tried the origional code in the datagrid prerender, the page prerender
and the itemdatabound events. Nothing. Also tried the following code
in all three. Still nada. Any more ideas?
Dim myDataGridITem As DataGridItem
For Each myDataGridITem In itemInfo.Items
Dim ddlPsize As DropDownList
ddlPsize = (itemInfo.Items(0).FindControl("ddlsizes"))
ddlPsize.Items.Insert(0, "Choose a Size")
Next
On Oct 9, 2:14 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.org> wrote:
> If you are with asp.net 2.0, you can set AppendDataBoundItems = true and add
> the size item in the markup.
[quoted text clipped - 41 lines]
>
> - Show quoted text -
Eliyahu Goldin - 09 Oct 2007 18:46 GMT
Should be
dlPsize = (myDataGridITem FindControl("ddlsizes"))

Signature
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
> tried the origional code in the datagrid prerender, the page prerender
> and the itemdatabound events. Nothing. Also tried the following code
[quoted text clipped - 58 lines]
>>
>> - Show quoted text -
Me LK - 09 Oct 2007 21:05 GMT
Yes!!! Thats IT!!!
Thanks
On Oct 9, 10:46 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.org> wrote:
> Should be
>
[quoted text clipped - 73 lines]
>
> - Show quoted text -
Me LK - 09 Oct 2007 21:07 GMT
Ooops not it. It shows correctly but now it send the top line (select
a size) to the database instead of the acutal size.
Did I miss something?