c# - Attempting to get a count of records from gridview based on a selected date from dropdownlist but cant? -


the problem lies upon selection of date in dropdown give count of last selection, not current. novice , thing can think of type of postback issue? gridview populates fine records selected ddl, cant head around why count rendered previous selection.

protected void ddlclassdate_selectedindexchanged(object sender, eventargs e) {         lblrecordcounter.text = "";         sqlconnection conn;         sqlcommand comm;         sqldatareader reader;          string connectionstring = configurationmanager.connectionstrings["gescdb"].connectionstring;          conn = new sqlconnection(connectionstring);          comm = new sqlcommand("select (*) gescdb" +             "where classdate=" + ddlclassdate.text, conn);          try         {              conn.open();             reader = comm.executereader();                             gridregistrants.datasource = reader;             gridregistrants.databind();                             reader.close();         }         catch         {          }                 {                           conn.close();             lblrecordcounter.text = gridregistrants.rows.count.tostring();          } 

in page_load method same, right? have move code following block:

if (!ispostback){     //your code here } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -