Dropdownlist add default blank while bind to sql server
Hi,
My dropdownlist is binded to a sql datasource.
I would like to have it list a blank entry on top and do not show real
data before user select it.
How can I do this.? Thanks
Re: Dropdownlist add default blank while bind to sql server
after you databind do this:
this.DropDownLi st1.Items.Inser t(0,"");
"syncwa" <syncwa@gmail.c om> wrote in message
news:p5c3v1pbb2 3rgq1ad51j8cnc4 q0bn9prcb@4ax.c om...[color=blue]
>
> Hi,
>
> My dropdownlist is binded to a sql datasource.
> I would like to have it list a blank entry on top and do not show real
> data before user select it.
> How can I do this.? Thanks[/color]
Re: Dropdownlist add default blank while bind to sql server
Sorry, I'm new to this. I put it in test.aspx.cs but it doesn't work.
Could you take a look at the following code to see where I should put
this? Regards
test.aspx.cs::
public partial class test : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
DropDownList1.I tems.Insert(0, "");
}
}
On Tue, 14 Feb 2006 06:07:19 -0500, "Alejandro Penate-Diaz"
<alexware69@hot mail.com> wrote:
[color=blue]
>after you databind do this:
>this.DropDownL ist1.Items.Inse rt(0,"");
>
>
>"syncwa" <syncwa@gmail.c om> wrote in message
>news:p5c3v1pbb 23rgq1ad51j8cnc 4q0bn9prcb@4ax. com...[color=green]
>>
>> Hi,
>>
>> My dropdownlist is binded to a sql datasource.
>> I would like to have it list a blank entry on top and do not show real
>> data before user select it.
>> How can I do this.? Thanks[/color]
>[/color]
Re: Dropdownlist add default blank while bind to sql server
I would suggest to databind programatically instead of using the IDE.
otherwise I jus dont know how to do it ;-)
"syncwa" <syncwa@gmail.c om> wrote in message
news:b3q3v11ikb c8qdla7837pkuu6 uu909h1v7@4ax.c om...[color=blue]
>
> Sorry, I'm new to this. I put it in test.aspx.cs but it doesn't work.
> Could you take a look at the following code to see where I should put
> this? Regards
>
>
> test.aspx.cs::
>
> public partial class test : System.Web.UI.P age
> {
> protected void Page_Load(objec t sender, EventArgs e)
> {
> DropDownList1.I tems.Insert(0, "");
> }
> }
>
>
> test.aspx:
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitl ed Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:DropDownLi st ID="DropDownLis t1" runat="server"
> DataSourceID="t estSqlDataSourc e1"
> DataTextField=" Company_Name" DataValueField= "Company_ID ">
> </asp:DropDownLis t><asp:SqlDataS ource ID="testSqlData Source1"
> runat="server" ConnectionStrin g="<%$
> ConnectionStrin gs:kConnectionS tring %>"
> SelectCommand=" SELECT [Company_Name], [Company_ID] FROM
> [Companies]"></asp:SqlDataSour ce>
>
> </div>
> </form>
> </body>
> </html>
>
>
>
> On Tue, 14 Feb 2006 06:07:19 -0500, "Alejandro Penate-Diaz"
> <alexware69@hot mail.com> wrote:
>[color=green]
>>after you databind do this:
>>this.DropDown List1.Items.Ins ert(0,"");
>>
>>
>>"syncwa" <syncwa@gmail.c om> wrote in message
>>news:p5c3v1pb b23rgq1ad51j8cn c4q0bn9prcb@4ax .com...[color=darkred]
>>>
>>> Hi,
>>>
>>> My dropdownlist is binded to a sql datasource.
>>> I would like to have it list a blank entry on top and do not show real
>>> data before user select it.
>>> How can I do this.? Thanks[/color]
>>[/color][/color]
Comment