vb.net - save dropdownlist selectedvalue from datagridview -


i have datagridview of questions dropdownlist of possible answers each question. want save answerid (dropdownlist.selecteditem.value) @ click of btnsavequestions_click event. however, after trying, version of visual web developer 2010 not give me errors, when viewing in internet explorer (version 10.0.9200.17377, , yes company policy requires have usable in internet explorer) states @ line "dim answerid string = ddanswer.selectedvalue" not set instance of object. assistance appreciated.

<asp:datagrid id="dgfacilityquestions_datagrid" runat="server" cssclass="dgblue" horizontalalign="center" width="90%" onitemcreated="dgfacilityquestions_datagrid_itemcreated" onitemdatabound="dgfacilityquestions_datagrid_itemdatabound" cellpadding="3"  autogeneratecolumns="false">    <headerstyle backcolor="#a09cbf" />    <columns>      <asp:boundcolumn datafield="questionid" readonly="true" headertext="questionid" visible="false"></asp:boundcolumn>      <asp:boundcolumn datafield="questiontext" headertext="question text">        <itemstyle width="60%" horizontalalign="left" />      </asp:boundcolumn>      <asp:templatecolumn headertext="answers">        <itemtemplate>          <asp:dropdownlist id="ddanswers" runat="server" datavaluefield="answerid" datatextfield="answertext"></asp:dropdownlist>        </itemtemplate>      </asp:templatecolumn>    </columns>  </asp:datagrid>

sub dgfacilityquestionsdatagrid()          ' create sql query populate grid, call, bind          dim sqlstring1 string = "select questionid, questiontext questions"          dgfacilityquestions_datagrid.datasource = global.asp.global.sqlselect(sqlstring1, "proposal")          dgfacilityquestions_datagrid.databind()      end sub ' end dgfacilityquestionsdatagrid()            sub dgfacilityquestions_datagrid_itemcreated(byval sender object, byval e datagriditemeventargs)          ' datagrid formatting before data bound datagrid - not care data put datagrid          select case e.item.itemtype              case listitemtype.item, listitemtype.alternatingitem, listitemtype.edititem                  ' add additional attributes based on mouseover , mouse out user actions                  e.item.attributes.add("onmouseover", "this.style.backgroundcolor = '#a09cbf'")                  e.item.attributes.add("onmouseout", "this.style.backgroundcolor = '#ffffff'")                  ' add buttons necessary control if buttons within datagrid                  ' cells(#) , controls(0) correspond column button resides in table starting @ 0 (0)                            end select      end sub ' end dgfacilityquesitonsdatagrid_itemcreated()            sub dgfacilityquestions_datagrid_itemdatabound(byval sender object, byval e datagriditemeventargs)          ' datagrid formatting once data bound - depends on data produced datagrid          if e.item.itemtype = listitemtype.item or _          e.item.itemtype = listitemtype.alternatingitem              if lblquestionsdone.text = "false"                  dim mydropdownlist dropdownlist = e.item.findcontrol("ddanswers")                  dim sqlstring string = "select answerid, answertext questionanswerslink questionid = " & e.item.cells(0).text                  global.asp.global.refresh_ddproposal(0, sqlstring, mydropdownlist)              else                  dim mydropdownlist dropdownlist = e.item.findcontrol("ddanswers")                  dim sqlstring string = "select answerid, answertext questionanswerslink questionid = " & e.item.cells(0).text                  global.asp.global.refresh_ddproposal(0, sqlstring, mydropdownlist)                  ' set showing value 1 chosen database              end if                        end if      end sub ' end dgfacilityquestionsdatagrid_itemdatabound()

sub btnsavequestions_click(sender object, e eventargs)          if btnsavequestions.text = "save answers" ' questions answered first time              dim integer = 0              each dr datagriditem in dgfacilityquestions_datagrid.items                  dim ddanswer dropdownlist = ctype(dgfacilityquestions_datagrid.findcontrol("ddanswers"), dropdownlist)                  dim answerid string = ddanswer.selectedvalue                  if answerid <> 0                      global.asp.global.sqlinsert("insert proposalfacilityquestionlink (proposalfacilityid, answerid) values ('" & lblfacilityid.text & "','" & answerid & "')")                  end if                  = + 1              next          elseif btnsavequestions.text = "save changes" ' answers changed                                      end if      end sub ' end btnsavequestions_click()


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -