Don't forget the magic that is DataTextFormatField...if you need it.

Thanks,

Shawn Wildermuth
[EMAIL PROTECTED]

> -----Original Message-----
> From: dotnet discussion [mailto:[EMAIL PROTECTED]]
> On Behalf Of Kirk Jackson
> Sent: Thursday, May 02, 2002 9:07 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] DropDownList binding
>
>
> If you don't specify a DataTextField in the drop down list's
> properties, then I think it just defaults to calling
> ToString() on each Data Item.
>
> You probably also need a DataValueField.
>
> Kirk
>
>
>
> -----Original Message-----
> From: Dawid Greyvenstein [AST EH]
> [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 2 May 2002 9:18 p.m.
> To: [EMAIL PROTECTED]
> Subject: [DOTNET] DropDownList binding
>
>
> I am trying to bind a DropDownList  to a sqlDataReader. I get
> the correct amount of options in the list, but the text is
> 'System.Data.Common.DbDataRecord' for all the options in the
> list. What am I doing wrong?
>
>       private void Page_Load(object sender, System.EventArgs e)
>       {
>
>             // connect to database
>             SqlConnection SqlConn = new SqlConnection(connStr);
>             SqlConn.Open();
>             // get data
>             string SQL = "SELECT pub_id,pub_name FROM
> publishers ORDER BY pub_name";
>             SqlCommand sqlCommand1 = new SqlCommand(SQL,SqlConn);
>             SqlDataReader reader = sqlCommand1.ExecuteReader();
>             // do binding
>             DropDownList1.DataSource = reader;
>             DropDownList1.DataBind();
>       }
>
> ______________________________________________
>
> "This information is intended only for the person or entity
> to which it is addressed and may contain private,
> confidential, proprietary and/or privileged material and may
> be subject to confidentiality agreements.
>
> Any review, retransmission, dissemination, or any other use
> of or taking of any action in reliance upon this information,
> by persons or entities other than the intended recipient, is
> prohibited.
>
> If you received this in error, please contact the sender and
> delete the material from all storage media.
>
> The company is neither liable for proper, complete
> transmission of the information contained in this
> communication, any delay in its receipt or that the mail is
> virus-free"
>
> You can read messages from the DOTNET archive, unsubscribe
> from DOTNET, or subscribe to other DevelopMentor lists at
> http://discuss.develop.com.
>
> You can read messages from the
> DOTNET archive, unsubscribe from DOTNET, or subscribe to
> other DevelopMentor lists at http://discuss.develop.com.
>

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to