javascript - Perform select Query on selectedDate of CalendarExtender -
i want perform select query on selecteddate value of calendarextender in asp.net. have 1 dummy button (visible=false) , perform button click event on calendar extendar of
onclientdateselectionchanged="checkdate"
and javascript function "checkdate" is
<script type="text/javascript"> > function checkdate(sender, args) { > var clientdate = sender._selecteddate; > __dopostback('button1', ''); > } </script>
and code behind file on button click event
> protected void button1_click(object sender, eventargs e) > { > //txtdate.text = convert.tostring(calendarextender1.selecteddate); > string cs = configurationmanager.connectionstrings["dbcs"].connectionstring; > using (sqlconnection con = new sqlconnection(cs)) > { > gvalreadyallocated.visible = true; > sqlcommand cmd = new sqlcommand("select date,empname,timeslot,topic,classroomno tbltimeslotdetails > date=@calenderdate", con); > con.open(); > cmd.parameters.addwithvalue("@calenderdate",); > using (sqldatareader rdr = cmd.executereader()) > { > datatable dt = new datatable(); > dt.columns.add("date"); > dt.columns.add("name"); > dt.columns.add("timeslot"); > dt.columns.add("topic"); > dt.columns.add("classroom number"); > > while (rdr.read()) > { > datarow datarow = dt.newrow(); > > datarow["date"] = convert.tostring(rdr["date"]); > > datarow["name"] = rdr["empname"]; > datarow["timeslot"] = rdr["timeslot"]; > datarow["topic"] = rdr["topic"]; > datarow["classroom number"] = rdr["classroomno"]; > dt.rows.add(datarow); > } > //gvalreadyallocated.columns[0].headertext = "already allocate data date"; > gvalreadyallocated.datasource = dt; > gvalreadyallocated.databind(); > > //gvalreadyallocated.datasource = rdr; > //gvalreadyallocated.databind(); > } > } > }
but how pass value @calenderdate parameter?
cmd.parameters.addwithvalue("@calenderdate",);
i want display 1 gridview selecteddate match date of database.
you need cast column in date
, value
want match
sqlcommand cmd = new sqlcommand("select date,empname,timeslot,topic,classroomno tbltimeslotdetails cast(datecol date)=cast(@calenderdate date),con
and value of parameter value of calenderextender selected date.
cmd.parameters.addwithvalue("@calenderdate",convert.tostring(calendarextender1.selecteddate));
Comments
Post a Comment