Reputation: 65
On drop down list selected Index Change i want bind Drop Down List according the condition. I am doing this and data is showing if i am using break point but On Front End Drop Down List is not Bind. it shows blank. My code is given below:
SqlParameter[] param6 = new SqlParameter[]
{ new SqlParameter("@status","drivershow"),
new SqlParameter("@FromDateWithStartTime",driverdate),
new SqlParameter("@dayvalue",dayvalue),
};
List<clsDropDown> assigneddriver = comnFunctionObj.getDropDownList(clsConstant.SP_GET_CAR_BOOKING_STATUS, param6);
ddldriver.Items.Clear();
for (int i = 0; i < assigneddriver.Count; i++)
{
if (!ddldriver.Items.Contains(new ListItem(assigneddriver[i].DisplayFieldText.Trim(), assigneddriver[i].ValueFieldText.Trim())))
{
ddldriver.Items.Add(new ListItem(assigneddriver[i].DisplayFieldText.Trim(), assigneddriver[i].ValueFieldText.Trim()));
}
}
Upvotes: 2
Views: 451
Reputation: 10565
Make sure you bind the data after adding items to DropDownlist as:ddldriver.DataBind();
ddldriver.Items.Clear();
for (int i = 0; i < assigneddriver.Count; i++)
{
// add items
}
// now bind the Data to the Dropdownlist
ddldriver.DataBind();
Check also if assigneddriver
list is not null.
Upvotes: 1