c# - Search on the basis of dropdown values -



c# - Search on the basis of dropdown values -

i have dropdown in have 2 options, a. selected b. not selected.

i want whenever user selects option, search should filter on basis. have column of selection in gridview has both alternative selected , not selected. values coming table.

please see html of dropdown , button reference:

<div style="float: left;"> <asp:dropdownlist id="ddlsort" runat="server" autopostback="false" onselectedindexchanged="ddlsort_selectedindexchanged"> <asp:listitem text="--select--" value="1"></asp:listitem> <asp:listitem text="selected" value="2"></asp:listitem> <asp:listitem text="not selected" value="3"></asp:listitem> </asp:dropdownlist> <asp:button id="btnsortselection" runat="server" text="sort selection" onclick="btnsortselection_click" /> </div>

i tried below mentioned code page refreshes , dropdown within gridview loses value. did not returns search result.:-

protected void ddlsort_selectedindexchanged(object sender, eventargs e) { sqlconnection conn = new sqlconnection(system.configuration.configurationmanager.connectionstrings["defaultsqlconnectionstring"].connectionstring); //create connection sqlcommand cmd = new sqlcommand("select * career.applicant selection =@selected", conn); cmd.parameters.addwithvalue("@selection", ddlsort.selectedvalue); }

i want stop dropdownlist values postback , should work when sorted

please see code updated panel:-

<asp:updatepanel runat="server" id="updateapplicants"> <contenttemplate> <div style="border: 1px solid #a8a8a8; width: 920px;"> <asp:gridview id="gv_applicants" runat="server" autogeneratecolumns="false" allowpaging="true" width="920" pagesize="5" onpageindexchanging="gv_applicants_pageindexchanging" onrowcommand="gv_applicants_rowcommand" emptydatatext="no applicants found." allowsorting="true" onsorting="gv_applicants_sorting" onrowdatabound="gv_applicants_rowdatabound" rowstyle-cssclass="a12" alternatingrowstyle-cssclass="a22" forecolor="#333333" gridlines="none" cssclass="table_box" headerstyle-height="35px" datakeynames="jobid"> <alternatingrowstyle backcolor="#f0f0f0" /> <columns> <asp:boundfield datafield="firstname" headertext="first name" headerstyle-width="84" /> <asp:boundfield datafield="lastname" headertext="last name" headerstyle-width="106" /> <asp:boundfield datafield="contactnumber" headertext="contact" headerstyle-width="98" /> <asp:boundfield datafield="email" headertext="email" headerstyle-width="150" /> <asp:templatefield headertext="position" sortexpression="position" headerstyle-width="107"> <itemtemplate> <%# eval("job.position") %> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="location" sortexpression="location" headerstyle-width="100"> <itemtemplate> <%# eval("job.location") %> </itemtemplate> </asp:templatefield> <asp:boundfield datafield="applieddate" dataformatstring="{0:mmmm dd, yyyy}" headertext="date of application" readonly="true" headerstyle-width="121" /> <asp:templatefield headertext="action" headerstyle-horizontalalign="center"> <itemtemplate> <asp:linkbutton id='lnkview' commandname='v' text='view' runat='server' commandargument='<%# eval("applicantid") %>'></asp:linkbutton> | <asp:linkbutton id='lnkdel' commandname='d' text='delete' runat='server' commandargument='<%# eval("applicantid") %>' onclientclick="return confirm('are sure delete?');"></asp:linkbutton> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="selection"> <itemtemplate> <asp:dropdownlist id="ddlselection" runat="server" enableviewstate="true" autopostback="true"> <asp:listitem text="none" value="1"></asp:listitem> <asp:listitem text="selected" value="2"></asp:listitem> <asp:listitem text="not selected" value="3"></asp:listitem> </asp:dropdownlist> </itemtemplate> </asp:templatefield> <asp:boundfield datafield="jobid" headertext="job id" visible="false" readonly="true" /> </columns> <editrowstyle backcolor="#2461bf" /> <footerstyle backcolor="#d8dada" font-bold="true" /> <headerstyle backcolor="#d8dada" font-bold="true" /> <pagerstyle backcolor="#d8dada" horizontalalign="center" /> <rowstyle backcolor="white" borderstyle="solid" bordercolor="#a8a8a8" borderwidth="1px" height="35" /> <selectedrowstyle backcolor="#d1ddf1" font-bold="true" forecolor="#333333" /> </asp:gridview> </div> <br /> <br /> <div id="divdetails" runat="server" class="force-overflow"> <div class="scrollbar" id="style-1"> <div style="border-left: 1px solid #a8a8a8; border-right: 1px solid #a8a8a8;"> <asp:detailsview id="dv_applicants" headerstyle-font-bold="true" headerstyle-backcolor="#f7e1e1" runat="server" autogeneraterows="false" allowpaging="false" headertext="applicant details" ondatabound="dv_applicants_databound" width="912px" backcolor="#f0f0f0" borderstyle="solid" borderwidth="1" bordercolor="#f0f0f0" rowstyle-height="30" font-size="10"> <fields> <asp:templatefield headertext="position" headerstyle-cssclass="c_width"> <itemtemplate> <%#eval("job.position") %> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="location" headerstyle-cssclass="c_width"> <itemtemplate> <%#eval("job.location") %> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="business unit" headerstyle-cssclass="c_width"> <itemtemplate> <%#eval("job.businessunit") %> </itemtemplate> </asp:templatefield> <asp:boundfield datafield="firstname" headertext="first name" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="lastname" headertext="last name" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="contactnumber" headertext="contact" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="email" headertext="email" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="pan" headertext="pan" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="dob" dataformatstring="{0:mmmm dd, yyyy}" headertext="date of birth" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="graduation" headertext="graduation" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="gradother" headertext="other" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="graddate" dataformatstring="{0:mmmm dd, yyyy}" headertext="graduation date" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="postgraduation" headertext="post graduation" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="pgother" headertext="other" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="pgdate" dataformatstring="{0:mmmm dd, yyyy}" headertext="post graduation date" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="anyotherqual" headertext="any other qualification" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="currentorg" headertext="organization" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="currentdesignation" headertext="designation" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="currentfunctionaldesig" headertext="current functional designation" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="currentctc" dataformatstring="{0} lakhs per annum" headertext="ctc" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="yrsincurrentrole" headertext="current experience" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="totalexp" headertext="total experience" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="keyskills" headertext="skills" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="city" headertext="city" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="state" headertext="state" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="country" headertext="country" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:templatefield headertext="willing relocate" controlstyle-cssclass="c_width" headerstyle-cssclass="c_width"> <itemtemplate> <%# convert.toboolean(eval("willingtorelocate")) == true ? "yes" : "no" %> </itemtemplate> </asp:templatefield> <asp:boundfield datafield="locationpreference" headertext="location preference" headerstyle-width="190" headerstyle-font-bold="true" /> <asp:boundfield datafield="applieddate" dataformatstring="{0:mmmm dd, yyyy}" headertext="date of application" readonly="true" headerstyle-font-bold="true" /> <asp:hyperlinkfield datanavigateurlfields="cvfilepath" text="view resume" controlstyle-forecolor="white" controlstyle-cssclass="bg" target="_blank" /> </fields> </asp:detailsview> </div> </div> </div> </contenttemplate> </asp:updatepanel>

c# asp.net

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -