items.insert into dropdown in datagrid

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
 
E

Eliyahu Goldin

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
 
M

Me LK

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

Eliyahu Goldin

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

Me LK

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

Me LK

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top