Fork me on GitHub
在GridView的中有一个DropDownList,并且DropDownList有回传事件

在GridView的中有一个DropDownList,并且DropDownList有回传事件

 最近做一个项目,需要在GridView中的ItemTemplate中添加一个DropDownList,并且当我选择这个DropDownList得时候,他需要向服务器回传数据:

如下图:

 

一开始想在GridView中的事件中写呢,可是DropDownList又没有CommandName属性

所以只有在DropDownList得SelecedIndexChanged事件中写了,具体步骤:
在GridView得编辑状态下,双击DropDownList就会进入到下面的事件中,代码如下:

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList Type = sender as DropDownList;  
        TableCell cell = (TableCell)Type.Parent;
        GridViewRow item = (GridViewRow)cell.Parent;
       string sql = "Update t_MemberInfo set YX=" + Type.SelectedValue+" and where Id="+item.Cells[0].Text;
        dal.RunSql(sql);
       gridViewBind();   / /GridView绑定事件
       

    }

posted on 2014-05-06 17:59  HackerVirus  阅读(190)  评论(0编辑  收藏  举报