日期:2014-05-17 浏览次数:20630 次
<asp:templatefield headertext="单品促销">
<itemtemplate>
<asp:dropdownlist id="DropDownList1" runat="server" AutoPostBack="true" OnTextChanged="DropDownList1_TextChanged" />
</itemtemplate>
</asp:templatefield>
string txt = ((DropDownList)GridView1.Rows[i].FindControl("DropDownList1")).SelectedItem.Text.ToString();//这里错误,提示:System.NullReferenceException: 未将对象引用设置到对象的实例。
string txt = ((DropDownList)GridView1.Rows[i].FindControl("DropDownList1")).SelectedItem.Value; //同样错误。
((DropDownList)GridView1.Rows[i].FindControl("DropDownList1")).SelectedValue.ToString(); //返回空值
DropDownList ddl = (DropDownList)GridView1.Rows[i].FindControl("DropDownList1");
string txt = ddl.SelectedValue;
((DropDownList)this.GridView1.Rows[e.RowIndex].Cells[4].FindControl("DropDownList1")).SelectedItem.Text