Labels

Tuesday, February 3, 2009

ListControl.AppendDataBoundItems

Hi,

 

This blog post summarizes a simple approach for inserting ‘—Select—‘in the DropDown at position zero.

 

 

Approach 1
 
ddlDealerGroup.DataSource = Services.Lookup.GetVehicleMultiMatchSelectDealerGroupsList(LenderId, -1);
ddlDealerGroup.DataTextField = ConstantKey.DataTextField;
ddlDealerGroup.DataValueField = ConstantKey.DataValueField;
ddlDealerGroup.DataBind();
 
ddlDealerGroup.Items.Insert(0, new ListItem(mSelectOption, string.Empty));

 

 
Approach 2
 
<asp:DropDownList ID="DropDownList1" AppendDataBoundItems="true" runat="server" >
    <asp:ListItem Text="--Select--" Value="" />    
</asp:DropDownList>
 
ddlDealerGroup.DataSource = Services.Lookup.GetVehicleMultiMatchSelectDealerGroupsList(LenderId, -1);
ddlDealerGroup.DataTextField = ConstantKey.DataTextField;
ddlDealerGroup.DataValueField = ConstantKey.DataValueField;
ddlDealerGroup.DataBind();
 
 

 

 

 

 

 

Thanks & Regards,

Arun Manglick || Senior Tech Lead

No comments:

Post a Comment