asp.net - Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.UserControl -
my code ![enter image description here][1]
but getting null exception error :(
protected sub button1_click(sender object, e eventargs) handles button1.click dim textquestionselected new list(of integer) dim imagequestionselected new list(of integer) dim text_question_id integer dim image_question_id integer each gridviewrow gridviewrow in gridview1.rows if (ctype(gridviewrow.findcontrol("checkbox1"), checkbox).checked) text_question_id = convert.toint16(ctype(gridviewrow.findcontrol("small_int_question_id"), label).text) textquestionselected.add(text_question_id) end if next each gridviewrow1 gridviewrow in gridview2.rows if (ctype(gridviewrow1.findcontrol("checkbox2"), checkbox).checked) image_question_id = ctype(gridviewrow1.findcontrol("small_int_question_id"), label).text imagequestionselected.add(image_question_id) end if next
i used bound field instead label .. same error
you have check type of row is; it's header or footer row. check rowtype property create sure it's datarow.
if (row.rowtype == datacontrolrowtype.datarow) { //check command }
also according subject, create sure type converting same. help see snippet of markup.
asp.net vb.net
No comments:
Post a Comment