各位:请问一下怎样在DATAGRID的FooterTemplate邦定一个 DropDownList,并且DropDownList中的各项是动态邦定的????有没有实例
请邮[email protected]因小弟没有经常上网的条件

解决方案 »

  1.   

    protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Footer)
            {
                DropDownList ddlst = e.Item.FindControl("DropDownList1");
                ddlst.DataSource = myDataTable;
                ddlst.DataBind();
            }
        }
      

  2.   

    2楼的好像还要再加2句吧
    DropDownList1.DataTextField=“”
    DropDownList1.DataValueField = “”
      

  3.   

    protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Footer)
            {
                DropDownList ddlst = e.Item.FindControl("DropDownList1");
                ddlst.DataSource = ds;
                DropDownList1.DataTextField=""
                DropDownList1.DataValueField =""
                ddlst.DataBind();
            }
        }
      

  4.   

    *.aspx<FooterTemplate>
      <asp:DropDownList id=_ddlSearch runat="server" Width="96px" DataTextField="Id" DataValueField="Desc" AutoPostBack="True" OnSelectedIndexChanged="OnSelChange"  DataSource="<%# GetDropTable() %>"></asp:DropDownList>
    </FooterTemplate>*.aspx.cs
    //变化事件处理
    protected void OnSelChange(object sender, System.EventArgs e)
    //绑定的数据源
    protected DataTable GetDropTable()
      

  5.   

    DropDownList 的事件可以通过
    在 *.aspx.cs 中 添加事件函数
    protected void OnSelChange(object sender, System.EventArgs e)
    {
    }然后,通过 *.aspx
    <FooterTemplate>
      <asp:DropDownList ... runat="server" AutoPostBack="True" OnSelectedIndexChanged="OnSelChange" .../>
    </FooterTemplate>来绑定事件函数。