items.insert into dropdown in datagrid

  • Thread starter Thread starter Me LK
  • Start date Start date
M

Me LK

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.

--
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
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


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.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://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
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")

But it did nothing

Thanks
LK- Hide quoted text -

- Show quoted text -
 
Should be

dlPsize = (myDataGridITem FindControl("ddlsizes"))

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Me LK said:
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


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.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://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
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")

But it did nothing

Thanks
LK- Hide quoted text -

- Show quoted text -
 
Yes!!! Thats IT!!!



Thanks

Should be

dlPsize = (myDataGridITem FindControl("ddlsizes"))

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net




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")
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.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://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
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- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
 
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?
 
Back
Top