Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

items.insert into dropdown in datagrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Me LK - 09 Oct 2007 08:41 GMT
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
Eliyahu Goldin - 09 Oct 2007 10:14 GMT
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?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.