asp.net - n ASP .NET 4.5 SelectMethod is not able to bind data to grid view on button click -
i using asp.net 4.5 , , facing issue regarding data binding grid view using 'select method'.
the grid able bind data on custom paging too.
the issue lies in filtering data. have asp button, clicking on able filtered data using stored proc. time grid not able call method mentioned in aspx page grid in selectmethod.
<asp:gridview id="gemployee" runat="server" autogeneratecolumns="false" onrowcommand="gemployee_command" cellpadding="4" onrowdatabound="gemployee_rowdatabound" allowcustompaging="true" pagesize="10" pagersettings-visible="false" cssclass="mgrid" allowsorting ="true" alternatingrowstyle-cssclass="alt" itemtype="modelentitylayer.clsemployee" selectmethod="bindgrid" onsorting ="gemployee_onsorting" headerstyle-wrap="false" datakeynames="propclocknumber" >
code above shows properties have set grid view.
public iqueryable<clsemployee> bindgrid() { int inttotalpages = 0; objbalemployee = new clsemployeebal(); list<clsemployee> employee = null; if ((string)session["queryresult"] != null) { employee = objbalemployee.getpagewisedata(gemployee.pageindex, gemployee.pagesize, viewstate["sortexpression"] != null ? viewstate["sortexpression"].tostring() : viewstate["clocknumber"].tostring(), viewstate["sortorder"] != null ? viewstate["sortorder"].tostring() : "asc", ref inttotalpages, ((string)session["queryresult"])); session.remove("queryresult"); } else { if (convert.toint32(viewstate["iseditsearch"]) != 1) { employee = objbalemployee.getpagewisedata(gemployee.pageindex, viewstate["sortexpression"] != null ? viewstate["sortexpression"].tostring() : viewstate["clocknumber"].tostring(), viewstate["sortorder"] != null ? viewstate["sortorder"].tostring() : "asc", gemployee.pagesize, ref inttotalpages); } else { employee = objbalemployee.getpagewisedata(gemployee.pageindex, gemployee.pagesize, viewstate["sortexpression"] != null ? viewstate["sortexpression"].tostring() : viewstate["clocknumber"].tostring(), viewstate["sortorder"] != null ? viewstate["sortorder"].tostring() : "asc", ref inttotalpages, dlemployee.selectedvalue+" = '"+txtsearch.text.trim()+"'"); } } var lstemployee = employee.asqueryable(); if (inttotalpages > 0) { custompager.totalpages = inttotalpages %gemployee.pagesize == 0 ? inttotalpages /gemployee.pagesize : inttotalpages / gemployee.pagesize + 1; custompager.visible = true; lblnorecordsfound.visible = false; norecords.visible = false; } else { custompager.visible = false; lblnorecordsfound.visible = true; norecords.visible = true; } exportdata1.disablebtn(gemployee); exportdata.exportcheck = false; return lstemployee; }
the above code shows bindgrid
method have set selectmethod in grid.
protected void btngo_click(object sender, eventargs e)
{ viewstate["iseditsearch"] = "1"; hiddensearchfield.value = dlemployee.selectedvalue; hiddensearchvalue.value = txtsearch.text.trim(); gemployee.selectmethod = "bindgrid"; }
the above code written button click.
though have written gemployee.selectmethod = "bindgrid";
once again on click code, bindgrid
not getting fired. not able bind newly filtered data grid.
please guide me on this.
thanks.
i think you'll need add line @ end of btngo_click
explictly calls databind() on grid:
protected void btngo_click(object sender, eventargs e) { viewstate["iseditsearch"] = "1"; hiddensearchfield.value = dlemployee.selectedvalue; hiddensearchvalue.value = txtsearch.text.trim(); gemployee.selectmethod = "bindgrid"; gemployee.databind(); }
Comments
Post a Comment