Problem with Web Control Binding

A

Andrea Williams

I have a drop down control that I've added a list item that has a value of
zero and the text name is "[Select One]". And it shows up like it's
supposed to until I bind a dataset to it. The binding seems to remove the
list Item that I added. Is there something I have to set to keep the list
Item that I added via ASPX code? Has anyone been successful in having a
defuatl selection that is not in the data set?

ASPX code:
<asp:DropDownList id="cboConferenceID" runat="server" AutoPostBack="True">
<asp:ListItem Value="0">[Select One]</asp:ListItem>
</asp:DropDownList>

ASP C# code-behind:
this.cboConferenceID.DataSource = dsGeneric;
this.cboConferenceID.DataTextField = vstrDataTextField;
this.cboConferenceID.DataValueField = vstrDataValueField;
this.cboConferenceID.DataBind();

Thanks in advance,
Andrea

PS: VS.NET 2003 on WIN 2000
 
A

Andrea Williams

So I'm guessing that this behavior is by design??

I was able to Insert a row after the bind and that works!

Thanks!
Andrea


bruce barker said:
in the codebehind, add it after the bind

-- bruce (sqlwork.com)


Andrea Williams said:
I have a drop down control that I've added a list item that has a value of
zero and the text name is "[Select One]". And it shows up like it's
supposed to until I bind a dataset to it. The binding seems to remove the
list Item that I added. Is there something I have to set to keep the list
Item that I added via ASPX code? Has anyone been successful in having a
defuatl selection that is not in the data set?

ASPX code:
<asp:DropDownList id="cboConferenceID" runat="server" AutoPostBack="True">
<asp:ListItem Value="0">[Select One]</asp:ListItem>
</asp:DropDownList>

ASP C# code-behind:
this.cboConferenceID.DataSource = dsGeneric;
this.cboConferenceID.DataTextField = vstrDataTextField;
this.cboConferenceID.DataValueField = vstrDataValueField;
this.cboConferenceID.DataBind();

Thanks in advance,
Andrea

PS: VS.NET 2003 on WIN 2000
 

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

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top