c# - Dynamically assigned a Label Value and display a messages when values changes -
i have code c# gets second highest number table in database: value or result-set displayed in text-box. number changes every time new record inserted database.
i created label on form , display message every time value or text in textbox changed, dynamically.
in nutshell, every time record inserted, code runs , inserts number in textbox, display message on label every time text-box value changes.
private void datasets_load(object sender, eventargs e){ //connection strings string connstring = @" server=example;database=example;integrated security=true"; string sql = @"select max(clientid) clients clientid <> (select max(clientid) clients)"; sqlconnection conn = new sqlconnection(connstring); conn.open(); //create data adapter sqldataadapter da = new sqldataadapter(sql, conn); dataset ds = new dataset(); //fill dataset da.fill(ds, "clientid"); txtdisplaydata.text = ds.tables[0].rows[0].itemarray[0].tostring(); conn.close(); ds.dispose(); }
handle textchanged event , update label there e.g.
txtdisplaydata.textchanged += (sender, e) => { mylabel.text = "value changed " + (sender textbox).text; }
Comments
Post a Comment