Hi,
I'm trying to come up with a generic approach in setting the data resources for the combo box. Instead of always setting the following properties:
In my code behind, I'd like to pass the control and since I always know that my datasource will alway have id and name. I want the call to be a single instance.
I have a controller class call DDLController that does the following:
As you can see above I created 2-3 separate methods that will render the different combo box. However this methodology seems to redunant where I want to render the control only once. I'm not really sure how to make this generic. Any help on this design would be very helpful.
Thanks,
I'm trying to come up with a generic approach in setting the data resources for the combo box. Instead of always setting the following properties:
prioritylist.DataSource = "";
prioritylist.DataValueField = ARConstants.PriorityListName;
prioritylist.DataTextField = ARConstants.PriorityListId;
prioritylist.DataBind();
prioritylist.Items.Insert(0, new ListItem("", "0"));
prioritylist.SelectedIndex = 0;
In my code behind, I'd like to pass the control and since I always know that my datasource will alway have id and name. I want the call to be a single instance.
I have a controller class call DDLController that does the following:
public void LoadLookup(Page page, DropDownList ddlPriority, DropDownList ddlRM, DropDownList ddlBSE, DropDownList ddlDataType)
{
LoadPriorityList(page,ddlPriority);
LoadRFMList(page, ddlRM);
LoadBSEList(page, ddlBSE);
LoadSystemList(page, ddlDataType);
}
private void LoadPriorityList(Page page,DropDownList prioritylist)
{
prioritylist.DataSource = "";
prioritylist.DataValueField = ARConstants.PriorityListName;
prioritylist.DataTextField = ARConstants.PriorityListId;
prioritylist.DataBind();
prioritylist.Items.Insert(0, new ListItem("", "0"));
prioritylist.SelectedIndex = 0;
}
private void LoadRFMList(Page page, DropDownList rfmlist)
{
rfmlist.DataSource = "";
rfmlist.DataValueField = ARConstants.RFMId;
rfmlist.DataTextField = ARConstants.RFMName;
rfmlist.DataBind();
rfmlist.Items.Insert(0, new ListItem("", "0"));
rfmlist.SelectedIndex = 0;
}
Thanks,