asp.net - Only update controls in same row in ItemTemplate, ListView -



asp.net - Only update controls in same row in ItemTemplate, ListView -

i have next listview displayed.

the "si number" databound, , on selectedindex_changed, "job number" binded , same productdescription.

if select "si number" in "labelling line 1" line, of "job number" dropdowns populated.

how can avoid this?

below itemtemplate source:

<itemtemplate> <tr runat="server" class='<%# conditionalstring(eval("lineid"), "", "-memo-row-inactive") %>'> <td style="padding: 0px;"> <asp:updatepanel id="upincludeline" childrenastriggers="true" runat="server" updatemode="conditional"> <contenttemplate> <asp:checkbox id="chkincludeline" tooltip='<%# eval("lineid") %>' runat="server" text='<%# eval("linedesc") %>' checked='<%# isproductionlineselected(eval("lineid")) %>' font-bold='<%# isproductionlineselected(eval("lineid")) %>' cssclass="-memo-checkbox" autopostback="true" oncheckedchanged="chkincludeline_oncheckedchanged" /> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="chkincludeline" eventname="checkedchanged" /> </triggers> </asp:updatepanel> </td> <td class="-field-inactive" align="center"> <asp:label id="lbllineid" runat="server" text='<%# eval("lineid") %>' /> </td> <td class="-field-inactive" align="center"> <asp:label id="productiontypelabel" runat="server" text='<%# translatesizecode(eval("productiontype")) %>' /> </td> <td style="padding: 0px;"> <asp:dropdownlist width="160px" id="ddlsinumber" runat="server" datasourceid="activesalesinstructionsdata" datatextfield="salesinstructionnumber" datavaluefield="salesinstructionnumber" onselectedindexchanged="ddlsinumber_selectedindexchanged" autopostback="true" /> </td> <td class="-field-status" style="padding: 0px;"> <asp:dropdownlist width="160px" id="ddljobs" datasourceid="labelingjobdata" datavaluefield="job" datatextfield="job" runat="server"> </asp:dropdownlist> </td> <td style="padding: 0px;"> <div style="position: relative;"> <asp:panel id="pnlproductdesc" cssclass="-clip" width="200px" visible="false" runat="server" > <asp:label id="lblproductdesc" runat="server" cssclass="-memo-inactive-display-label" text='<%# getproductname(eval("lineid")) %>'></asp:label> <!--!isproductionlineselected(eval("lineid"))--> </asp:panel> <asp:updatepanel id="upproductcode" childrenastriggers="true" updatemode="conditional" runat="server"> <contenttemplate> <asp:dropdownlist id="lsproductcode" width="100%" visible="true" autopostback="true" datasourceid="labelingjobdata" datatextfield="stockcode" datavaluefield="stockcode" onselectedindexchanged="lsshippingid_onselectedindexchanged" runat="server"> </asp:dropdownlist> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="lsproductcode" eventname="selectedindexchanged" /> </triggers> </asp:updatepanel> </div> </td> </tr> </itemtemplate>

here selectedindexchanged:

protected void ddlsinumber_selectedindexchanged(object sender, eventargs e) { var ddl = (dropdownlist)sender; var selectedsi = ddl.selectedvalue.tostring(); hvsalesinstructionnumber.value = selectedsi; if (!string.isnullorempty(hvsalesinstructionnumber.value)) { var command = (dropdownlist)ddl.parent.findcontrol("ddljobs"); control.databind(); } }

on control.databind, bind dropdownlist sqldatasource.

when set datasource are: datasourceid="labelingjobdata", setting source every ddljobs dropdownlist in listview.

objectdatasources auto-bind on every page load, unless explicitly cancelled.

if set datasourceid property of data-bound control, command automatically binds info data source, needed. setting datasourceid property recommended method binding objectdatasource command data-bound control. alternatively, can set datasource property, must explicitly phone call databind method of data-bound control. can phone call select method programmatically @ time retrieve data.

because of this, set parameter value datasource, binds each ddljobs dropdownlist automatically. wouldn't have phone call databind().

to around this, suggest not using datasourceid in markup, instead set datasource in codebehind , bind 1 specific control.

protected void ddlsinumber_selectedindexchanged(object sender, eventargs e) { dropdownlist ddl = (dropdownlist)sender; string selectedsi = ddl.selectedvalue; if (!string.isnullorempty(selectedsi)) { dropdownlist command = (dropdownlist)ddl.parent.findcontrol("ddljobs"); control.datasource = yourgettermethod(selectedsi); control.databind(); } }

asp.net visual-studio-2010 listview c#-4.0

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -