我在下拉列表中绑定数据,如下所示
private void GetallAssociate()
{
var dsAssociate = AdminBL.Ins.selectAllAssociates();
if (dsAssociate.Tables[0].Rows.Count > 0)
{
ddlAssociate.DataSource = dsAssociate;
ddlAssociate.DataTextField = "AssociateName";
ddlAssociate.DataValueField = "Associateid";
ddlAssociate.DataBind();
ddlAssociate.Items.Add("ALL");
ddlAssociate.Items.Insert(0, "Select Associate");
}
}
在此我将参数(int)值作为 Associateid 传递,所以当我选择 ALL 选项时,会出现错误,例如无法将字符串转换为 int,所以我在做什么?