zoukankan      html  css  js  c++  java
  • gridview下拉框

     protected void GVrentDetails_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            ListItem NewItem;
            string sql;
            DataTable dt;
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DropDownList drop01 = (DropDownList)e.Row.FindControl("ddlRentType");
                sql = "select * from dict where fieldMark='rentType'";
                dt = commonCls.GetDataTable(sql);
                drop01.DataSource = dt;
                drop01.DataTextField = "fieldValue";
                drop01.DataValueField = "fieldValue";
                drop01.DataBind();
                NewItem = new ListItem();
                NewItem.Value = "qxz";
                NewItem.Text = "请选择";
                drop01.Items.Insert(0, NewItem);
                drop01.SelectedValue = DataBinder.Eval(e.Row.DataItem, "rentType").ToString();
    
                DropDownList drop02 = (DropDownList)e.Row.FindControl("ddlInExpType");
                sql = "select * from dict where fieldMark='InExpType'";
                dt = commonCls.GetDataTable(sql);
                drop02.DataSource = dt;
                drop02.DataTextField = "fieldValue";
                drop02.DataValueField = "fieldValue";
                drop02.DataBind();
                NewItem = new ListItem();
                NewItem.Value = "qxz";
                NewItem.Text = "请选择";
                drop02.Items.Insert(0, NewItem);
                drop02.SelectedValue = DataBinder.Eval(e.Row.DataItem, "InExpType").ToString();
            }
        }
    View Code

    在RowDataBound事件中绑定下拉框,设置值drop01.SelectedValue = DataBinder.Eval(e.Row.DataItem, "rentType").ToString();

  • 相关阅读:
    phpcms新建模板页教程
    Linux方向职业规划
    Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroad
    Codeforces Round #396(Div. 2) A. Mahmoud and Longest Uncommon Subsequence
    ACM hdu 3336 Count the string
    ACM KMP 格式输入导致TLE
    swing JTable 更新数据
    swing JTable
    HashMap 和 HashTable 区别
    Java中next()和nextLine()
  • 原文地址:https://www.cnblogs.com/zhaolijing910/p/3106387.html
Copyright © 2011-2022 走看看