在gridview的template中放入textbox读值的问题
在gridview的template中放入textbox,现在想把textbox.text的值读出来。
我用了gridview.row().cells().controls()
后面就不会写了。
[解决办法]
无法将类型为“System.Web.UI.LiteralControl”的对象强制转换为类型“System.Web.UI.WebControls.DropDownList
==
这里已经说得很清楚了,你找到的不是DropDownList,而是个LiteralControl
强烈建议你使用FindControl方法根据控件的id找到控件
Dim mytxt As DropDownList
Dim mytxt2 As DropDownList
mytxt = CType(Me.GridView1.Rows(i).FindControl("对应的DropDownList的ID 可能是DropDownList1"), DropDownList)
mytxt2 = CType(Me.GridView1.Rows(i).FindControl("对应的DropDownList的ID 可能是DropDownList2"), DropDownList)
con3(k) = mytxt.Text + "到" + mytxt2.Text
k = k + 1