Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 25th, 2007, 09:42 PM
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default dropdownlist inside a datalist's itemtemplate

I followed this site and I got it to work as the site shows - http://aspalliance.com/142_Working_w...s_in_DataGrids

However, with my scenario I need to figure out how to take the ID from the datalist and pass it to my Function:

<asp:DropDownList id="ddlSizes"
            DataSource="<%# BindSize(DataBinder.Eval(Container.DataItem, "ID")) %>"

This returns a malformed syntax error for the aspx page.

Basically I'm returning a lot of data that has specific data associated with it and I want to dump that data in a DropDownList.

If it can be handled in the codebehind that would be best but when I try that I get "object reference not set to an instance of an object..." for my DDL.

Code Behind attempt:
list.DataSource = datalayer.GetProducts()
BindSizes(list.DataKeyField) 'list.DataKeyField is wrong... I can't figure out how to send the ID.

Private Sub BindSizes(ByVal productId As String)
        Dim connection As New OleDbConnection(connectionString)
        ' Create and initialize the command object
        Dim strSQL As String = "SELECT SizeID, ProductID, Sizes & ' - ' & Price AS Sizes, Price " & _
                                 "FROM Sizes " & _
           "WHERE (ProductID = " & productid & ")"
        Dim objCmd As New OleDbCommand(strSQL, connection)
        Dim objDR As OleDbDataReader
            objCmd.ExecuteReader(CommandBehavior.CloseConnecti on)
        Catch e As Exception
            Throw e
        End Try
        Dim myDDL As DropDownList = list.FindControl("ddlSizes")
        myDDL.DataSource = objCmd
        myDDL.DataTextField = "Sizes"
        myDDL.DataValueField = "SizeID"
    End Sub

  #2 (permalink)  
Old April 26th, 2007, 04:44 PM
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts


DataSource='<%# BindSizes(DataBinder.Eval(Container.DataItem, "ProductID")) %>'

Instead of

DataSource="<%# BindSizes(DataBinder.Eval(Container.DataItem, "ProductID")) %>"

  #3 (permalink)  
Old April 26th, 2007, 05:53 PM
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts

I am trying to use code behind to make the DropDownList not visible if there is no data but I am unsure how to accomplish this. I also want to update the DataList's price value once the DrowDownList has been selected. Does anyone know of any good articles on how to accomplish this?


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two DropDownList Inside a Gridview ilayaraja ASP.NET 3.5 Basics 3 December 5th, 2008 06:26 PM
DropDownList Inside a datagrid @shish ASP.NET 1.0 and 1.1 Professional 3 January 29th, 2007 07:24 PM
dropdownlist inside datagrid myunus General .NET 11 October 29th, 2006 07:37 AM
is it possilble to do logic inside an itemtemplate Raif ASP.NET 1.0 and 1.1 Professional 5 August 19th, 2004 02:20 PM
dropdownlist inside datagrid shaileshmark General .NET 5 June 27th, 2004 05:18 AM

All times are GMT -4. The time now is 07:54 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.