请教怎样拿动态Checkbox的值?我先定了一个 mybox(10) as checkbox, mycount as integer,
然后在pageload里: for count = 1 to 10
Mybox(count) = new checkbox
然后把Mybox(count) 放在一个HTML TABLE之内.
但当我在一个button click event中想做:
Count = 1
If mybox(count).checked= true then
Xxxx
End if 时,  ERROR -- “object reference not set to an instance of an object” 

解决方案 »

  1.   

    首先,你要获得你动态生成的checkbox的clientID,一般都是“ctl00$FormPalace$”+页面名+“$”+控件ID的形式;你可以生成页面后查看页面的源代码获得;
    然后,通过下面的语句应该能获得是否选择
    string Selectedvalue = Request.Form[clientID].ToLower();
    selectedValue应该等于“true”或“false”;
    (我是后台动态生成radiobutton,可以获得radiobutton的Value,你试试吧)