Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 28th, 2004, 01:25 PM
Registered User
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to bind data to a dropdown in a datalist thats


I am currently writing a LiveUpdate manager. Although everything is going quite smoothly, I have just encountered my first annoyance.

In SQLServer 2000, I have a Version table in which a FK references the Software to which this version applies.

Now my datalist is binded to the version table and I have a dropdown in the edit template which should contain a) the PK of the software as itemvalue and b)the name of the software as itemtext. Everything is fine on other forms where the dropdown isn't in a datalist.

My problem is when using the FindControl method of a DataList item, it always returns "Nothing" as object reference, and therefore, I can't bind the software data to my dropdown I have tried to bind the data in numerous events, but always with the same result, object reference is always null... OnUpdate won't cut it, because a click of some sort is needed, and OnEdit returns a null object reference when trying to find the control.

Any insight on an event i might have missed? Let me know if posting code might help...
Old April 28th, 2004, 01:52 PM
Registered User
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Posting has a sense of irony it seems...

After a day of scratching my head, finally found my answer minutes after posting :)

In the EditItemTemplate, just had to add a function call, no need for events.

<asp:DropDownList id="DropDownLogiciel" runat="server" CssClass="TextItemEdit" DataSource="<% #GetDropDownData() %>" DataTextField = "logiciel" DataValueField="id">

GetDropDownData() return a filled dataset... how easy once you think of it hehe

Hope this helps someone else :)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bind two dropdown without autopostback xs2bharat ASP.NET 1.0 and 1.1 Basics 20 May 6th, 2007 02:23 AM
can we bind datagrid and dropdown list rakeshgv SQL Server 2000 0 August 21st, 2006 02:13 AM
How to bind date field in a datalist deepak kavety .NET Web Services 2 January 19th, 2005 12:19 AM
Bind records from the table to a datalist control macupryk General .NET 1 October 13th, 2004 11:59 AM
bind 2 tables in a datalist life_s Ng ASP.NET 1.0 and 1.1 Basics 4 December 19th, 2003 04:37 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.