gridview gd里面的编辑模板有一个dropdownlist chatrate,需要在点击编辑按钮后
对chatrate控件进行填充数据,后台有一个类,里面有一个Fillxxx(Dropdownlist drop)的方法
要怎么处理才能实现绑定,不是很熟悉下午弄了很久都没有实现,请dx帮帮忙
谢谢

解决方案 »

  1.   

    可以参考
    http://singlepine.cnblogs.com/archive/2005/11/01/266538.html
      

  2.   

    singlepine(小山) 大哥,你那个是1.1的,2.0里面的gridView没有
    ItemDataBound,他有RowData....
    但是参数也变了,e.Item.ItemType 这些都没有了,知道他用什么新的方法吗?
      

  3.   

    //*****在后写一个获取需要邦定的数据
    //*****然后在前台邦定public DataSet GetColumn()
    {   DataSet DSet=(new WebServices.FrinedServices()).SystemColumr_Ex_Filter();
       
       return DSet;
    }//****前台模版列邦定
      <asp:DropDownList ID="drpList" runat="server" DataSource="<%=GetColumn()%>">
                </asp:DropDownList>//****第二种方法
     protected void GView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            DropDownList drpList = null;        foreach (GridViewRow gdVRow in GView.Rows)
            {
                //****获取dropdownlist控件
                drpList = (DropDownList)gdVRow.FindControl("drpList");            //****调用函数,进行数据邦定
                DataBindDrpColum(ref drpList, true);
            }
            
        }    private DataSet DataBindDrpColum(ref DropDownList drpList,bool IsBool)
        {
            drpList.Items.Clear();        if (IsBool == true)
            {
                drpList.Items.Add("请选择");
            }        DataSet DSet = (new WebServices.SystemColumnServices()).SystemColumn_Ex_Filter();        foreach (DataRow dRow in DSet.Tables[0].Rows)
            {
                ListItem LItem = new ListItem(dRow["ColumnName"].ToString(), dRow["ColumnID"].ToString());            drpList.Items.Add(LItem);
            }
        }
      

  4.   

    谢谢zhangxiaopin(zxp) :
    其实我之前写的就跟你差不多,一直不行,
    昨天看了你的代码怎么弄还是不行,一直都是
    drpList = (DropDownList)gdVRow.FindControl("drpList");  类似这样写的
    一直找不到
    后来改用drpList =gdVRow.FindControl("drpList") as  DropDownList;居然就可以了
    很晕
    用as的区别不是只当找不到就不转直接赋值为null吗,真不明白怎么会这样