在gridview中有两个dropdownlist
这种情况下,
如何做级联呢。那个SelectedIndexChanged不知道怎样去弄了

解决方案 »

  1.   


    参考:protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow gvr = (sender as DropDownList).NamingContainer as GridViewRow;
        if(gvr != null)
        {
             DropDownList ddl = gvr.FindControl("DropDownList2") as DropDownList;
             if(ddl != null)
             {
                  ddl.DataSource = "你要绑定的数据源";
                  ddl.DataTextField = "设置DataTextField";
                  ddl.DataValueField = "设置DataValueField";
                  ddl.DataBind();
             }
        }
    }
      

  2.   

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    if (e.Row.FindControl("DropDownList1") != null)
    {
    DropDownList ddl = ( DropDownList)e.Row.FindControl(" DropDownList1");
    ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
    }
    }
    }
    protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
    {
    DropDownList Type = sender as DropDownList;
    TableCell cell = (TableCell)Type.Parent;
            GridViewRow item = (GridViewRow)cell.Parent;   }
      

  3.   

    找DropDownList的事件selectIndexChanged,在属性栏可以设置。
    帮楼主顶了。