如何初始化DataGrid中的DropDownList

来源:互联网 发布:淘宝达人平台 编辑:程序博客网 时间:2024/04/27 20:09

private void dgDoubleDrp_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
  {
   //判断是否是编辑项
   if (e.Item.ItemType == ListItemType.EditItem)
   {
    //找到编辑项中的drpOrder下拉列表控件
    DropDownList drpOrderID = (DropDownList) e.Item.FindControl("drpOrder");
    //设置在上个操作中drpOrder下拉列表中选中的项
    drpOrderID.SelectedIndex = drpOrderID.Items.IndexOf(drpOrderID.Items.FindByText(orderID));

    //找到编辑项中的drpProduct下拉列表控件
    DropDownList drpProductID = (DropDownList) e.Item.FindControl("drpProduct");
    //设置在上个操作中drpProduct下拉列表中选中的项
    drpProductID.SelectedIndex = drpProductID.Items.IndexOf(drpProductID.Items.FindByText(productID));
   }
  }
 

原创粉丝点击