databinding to drop down list

Posts   
 
    
rai
User
Posts: 41
Joined: 25-Jan-2007
# Posted on: 21-Aug-2008 01:20:47   

Hello,

I am using llblgen version 2.5 with .net 2.0 and vs 2005 and database 2005 and coding woth c#.

I am adding a list of publication to a dropdown list the code is: ddlPublication.Datasource = PublicationMaster.GetAll(); ddlPublication.DataTextField = "PubName"; ddlPublication.DataBind();

My question is how can i add a default value in the drop down and also add the publication from the database. Is it possible.

any suggestions please

Jennifer
User
Posts: 8
Joined: 18-Jul-2008
# Posted on: 21-Aug-2008 02:23:51   

You can do it all in the aspx markup. The key is adding the ListItem and setting AppendDataBoundItems.


 <asp:DropDownList ID="DropDownListShipToPicker" runat="server"
        AppendDataBoundItems="True" 
        DataSourceID="LLBLGenProDataSourceShipToPicker" 
        DataTextField="ShipToName" DataValueField="ShipToId">
    <asp:ListItem Value="-1">Please Select</asp:ListItem>
 </asp:DropDownList>