我想在特定索引处添加“添加新”,但我不确定语法。我有以下代码:
protected void Page_Load(object sender, EventArgs e)
{
DRPFill();
if (!IsPostBack)
{
DropDownList1.Items.Add("Add New");
}
}
public void DRPFill()
{
if (!IsPostBack)
{
//Object
AddMajor objMajor = new AddMajor();
//Data Table
DataTable dtMajor = objMajor.find();
//Data Source
DropDownList1.DataSource = dtMajor;
DropDownList1.DataValueField = "MajorID";
DropDownList1.DataTextField = "MajorName";
//Data Bind
DropDownList1.DataBind();
}
}