foreach (GridViewRow item in this.GridView2.Rows)
                {
                    string DDL1 = ((DropDownList)item.Cells[1].FindControl("DDLDepotCategoryRM")).SelectedValue;

能不能判断DDL1 下拉取值
类似与if(DDL1 .Text=="一级")
{
 //然后根据DDL1 上传到sql 的相应类别
   string sql = "update ........."
}
但好像   DDL1的变量   不能.Text
应该怎么处理???

解决方案 »

  1.   

    DropDownList DDL1 = (DropDownList)item.FindControl("DDLDepotCategoryRM");DDL1.SelectedItem.Text
    DDL1.SelectedItem.Value
      

  2.   

    DDL1.    SelectedItem  点不出来的?
      

  3.   

    可以点出来的,并且有这个属性
    http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.dropdownlist_properties.aspx
      

  4.   

    foreach (GridViewRow item in this.GridView2.Rows)
     {
      DropDownList DDL1 = (DropDownList)item.FindControl("DDLDepotCategoryRM");
      if(DDL1 !=null && DDL1.SelectedItem!=null)
      {
       Response.Write(DDL1.SelectedItem.Text);
       Response.Write(DDL1.SelectedItem.Value);
      }