如何获取GridView里面模板列DropDownList控件选定项的值?
2013-07-13
展开全部
protected void gvOrder_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList ddlOrder = (DropDownList)e.Row.FindControl("ddlOrder");
}
protected void gvOrder_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int i = Convert.ToInt32(e.RowIndex);
string ID = gvOrder.Rows[i].Cells[0].Text.ToString();string OrderState = ((DropDownList)gvOrder.Rows[i].FindControl("ddlOrder")).SelectedItem.ToString();
string sql = "update 订单表 set 订单状态='" + OrderState + "'";
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
gvOrder.EditIndex = -1;
DataBind();
LoadOrder();
}
{
DropDownList ddlOrder = (DropDownList)e.Row.FindControl("ddlOrder");
}
protected void gvOrder_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int i = Convert.ToInt32(e.RowIndex);
string ID = gvOrder.Rows[i].Cells[0].Text.ToString();string OrderState = ((DropDownList)gvOrder.Rows[i].FindControl("ddlOrder")).SelectedItem.ToString();
string sql = "update 订单表 set 订单状态='" + OrderState + "'";
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
gvOrder.EditIndex = -1;
DataBind();
LoadOrder();
}
2013-07-13
展开全部
DropDownList ddlSex = (DropDownList)e.Row.FindControl("DDLSex"); string OrderState = ddlSex .Text ;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-13
展开全部
在gridView的GridView1_RowDataBound事件中:DropDownList ddlSex = (DropDownList)e.Row.FindControl("DDLSex");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询