drop down menu - VB.net Labels not populated from dropdown variable data on pageload, but update when dropdowns change -


i have declared variables based on dropdown text:

    dim strdatacollection string = ddldatacollection.text     dim stryear string = ddlyear.selecteditem.text     dim strsubject string = ddlsubject.text     dim strteachinggroup string = ddlteachinggroup.text     dim strsubgroup string = ddlsubgroup.selecteditem.text 

then i've called variables display in series of labels.

    lblheaderyear.text = "year " & stryear     lblheaderdatacollection.text = " " & strdatacollection     lblheadersubject.text = " " & strsubject     lblheaderteachinggroup.text = " " & strteachinggroup     lblheadersubroup.text = " " & strsubgroup 

however, on page load lblheaderyear label text populating, not rest of labels. yet when make selection dropdown lists display ok.

here asp in front of this:

      <div style="width:100%; height: 100%;">          <asp:label id="lbldatacollection" runat="server" text="data collection: " cssclass="label"></asp:label>         <asp:dropdownlist id="ddldatacollection" runat="server" datasourceid="dsdatacollection" datatextfield="datacollection" datavaluefield="datacollection" cssclass="dropdown" autopostback="true">         </asp:dropdownlist>          <asp:sqldatasource id="dsdatacollection" runat="server" connectionstring="<%$ connectionstrings:maltingsconnectionstring %>" selectcommand="select distinct datacollection subject order datacollection"></asp:sqldatasource>           <asp:label id="lblyear" runat="server" cssclass="label" text="year: "></asp:label>         <asp:dropdownlist id="ddlyear" runat="server" autopostback="true" cssclass="dropdown">             <asp:listitem selected="true">11</asp:listitem>             <asp:listitem>10</asp:listitem>             <asp:listitem>9</asp:listitem>             <asp:listitem>8</asp:listitem>             <asp:listitem>7</asp:listitem>         </asp:dropdownlist>           <asp:label id="lblsubject" runat="server" cssclass="label" text="subject: "></asp:label>         <asp:dropdownlist id="ddlsubject" runat="server" datasourceid="dssubject" datatextfield="subject name" datavaluefield="subject name" autopostback="true" cssclass="dropdown">         </asp:dropdownlist>         <asp:sqldatasource id="dssubject" runat="server" connectionstring="<%$ connectionstrings:maltingsconnectionstring %>" selectcommand="select distinct subject.name 'subject name', case when subject.name 'english' or subject.name 'english igcse' or subject.name 'mathematics' 0 else 1 end ordering, subject.datacollection expr1 student inner join subject on student.upn = subject.upn (student.stuyear = 11) , (subject.datacollection 'march 2013') order ordering, 'subject name'"></asp:sqldatasource>         <asp:label id="lblteachinggroup" runat="server" text="teaching group: " cssclass="label"></asp:label>         <asp:dropdownlist id="ddlteachinggroup" runat="server" datasourceid="dsteachinggroup" datatextfield="teaching group" datavaluefield="teaching group" autopostback ="true" cssclass="dropdown">             <asp:listitem selected="true" value="select all">select all</asp:listitem>         </asp:dropdownlist>          <br />         <asp:sqldatasource id="dsteachinggroup" runat="server" connectionstring="<%$ connectionstrings:maltingsconnectionstring %>" selectcommand="select 'select all' 'teaching group', 0 sortorder union select distinct subject.teachinggroup 'teaching group', 1 sortorder student inner join subject on student.upn = subject.upn (subject.name 'english') , (student.stuyear = 11) order sortorder, 'teaching group'"></asp:sqldatasource>          <asp:label id="lblsubgroup" runat="server" cssclass="label" style="font-size: 11px" text="subgroup: "></asp:label>         <asp:dropdownlist id="ddlsubgroup" runat="server" cssclass="dropdown" style="font-size: 11px" autopostback="true">             <asp:listitem selected="true">select all</asp:listitem>             <asp:listitem value="genf">girls</asp:listitem>             <asp:listitem value="genm">boys</asp:listitem>             <asp:listitem value="high">high attainers</asp:listitem>             <asp:listitem value="middle">middle attainers</asp:listitem>             <asp:listitem value="low">low attainers</asp:listitem>             <asp:listitem value="ppyes">pupil premium</asp:listitem>             <asp:listitem value="ppno">non-pupil premium</asp:listitem>             <asp:listitem value="fsmyes">free school meals</asp:listitem>             <asp:listitem value="fsmno">non-free school meals</asp:listitem>             <asp:listitem value="senyes">special educational needs</asp:listitem>             <asp:listitem value="senno">non-special educational needs</asp:listitem>             <asp:listitem value="sens">statemented</asp:listitem>             <asp:listitem value="sennos">non-statemented</asp:listitem>             <asp:listitem value="senayes">school action</asp:listitem>             <asp:listitem value="senano">non-school action</asp:listitem>             <asp:listitem value="senpyes">school action plus</asp:listitem>             <asp:listitem value="senpno">non-school action plus</asp:listitem>             <asp:listitem value="ealyes">english additional language</asp:listitem>             <asp:listitem value="ealno">non-english additional language</asp:listitem>             <asp:listitem value="lacyes">looked after children</asp:listitem>             <asp:listitem value="lacno">non-looked after children</asp:listitem>             <asp:listitem value="gandtyes">gifted , talented</asp:listitem>             <asp:listitem value="gandtno">non-gifted , talented</asp:listitem>             <asp:listitem value="giftedyes">gifted</asp:listitem>             <asp:listitem value="giftedno">non-gifted</asp:listitem>             <asp:listitem value="talentyes">talented</asp:listitem>             <asp:listitem value="talentno">non-talented</asp:listitem>         </asp:dropdownlist>           <br />           <br />           <asp:label id="lblheaderyear" runat="server" text="" cssclass="header"></asp:label>           <asp:label id="lblheaderdatacollection" runat="server" text="" cssclass="header"></asp:label>           <asp:label id="lblheadersubject" runat="server" text="" cssclass="header"></asp:label>           <asp:label id="lblheaderteachinggroup" runat="server" text="" cssclass="header"></asp:label>           <asp:label id="lblheadersubroup" runat="server" text="" cssclass="header"></asp:label>           <br />           <br />        </div> 

it looks you're not using 'selecteditem.text' property dropdownlist boxes. instead of

dim strdatacollection string = ddldatacollection.text dim stryear string = ddlyear.selecteditem.text dim strsubject string = ddlsubject.text dim strteachinggroup string = ddlteachinggroup.text dim strsubgroup string = ddlsubgroup.selecteditem.text 

do want:

dim strdatacollection string = ddldatacollection.selecteditem.text dim stryear string = ddlyear.selecteditem.text dim strsubject string = ddlsubject.selecteditem.text dim strteachinggroup string = ddlteachinggroup.selecteditem.text dim strsubgroup string = ddlsubgroup.selecteditem.text 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -