c# - Database to DropDownList and AutoPostBack to Label -
i have code this
protected void dropdownlist1_selectedindexchanged(object sender, eventargs e) { string strconnectionstring = configurationmanager.connectionstrings["sqlservercstr"].connectionstring; sqlconnection myconnection = new sqlconnection(strconnectionstring); myconnection.open(); string musisim = dropdownlist1.selecteditem.value; sqlcommand cmd = new sqlcommand("select b.hesap_no yaz..mardata.s_teklif b b.mus_k_isim = dropdownlist1.selecteditem.value", myconnection); label1.text = cmd.executereader().tostring(); myconnection.close();
i have customer name "mus_k_isim" , number "hesap_no"
all want is, (autopostback true) automaticly getting label "hesap_no" has number "mus_k_isim" in dropdownlist.
how can that?
error: description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.
your database doesn't know asp page or controls on ;-) you'll need re-work sql statement - first revision change thus:
sqlcommand cmd = new sqlcommand("select b.hesap_no yaz..mardata.s_teklif b b.mus_k_isim = '" + dropdownlist1.selecteditem.value + "'", myconnection);
so name selected in dropdownlist added sql query.
looking ahead, best kind of thing either parameterized query or stored procedure.
hth.
Comments
Post a Comment