.net - C# Delegate eventhandler SelectedIndexChanged -


i want pass value method lecmb_statut_selectedindexchanged, how can proceed?

i have code:

sqldatareader reader = comm.executereader();  while (reader.read()) {    ...    dropdownlist lecmb_statut = new dropdownlist();    string templabel = reader["libelle"].tostring();    string templabelveh = reader["libveh"].tostring() } 

how can pass these temp variables lecmb_statut_selectedindexchanged?

lecmb_statut.selectedindexchanged += new eventhandler(lecmb_statut_selectedindexchanged); 

you use tag property of dropdownlist. first, create simple dto:

public class labeldto {    public string label {get;set;}    public string labelveh {get;set;} }  

then:

while (reader.read()) {    ...    dropdownlist lecmb_statut = new dropdownlist();    labeldto lbl= new labeldto(){label=reader["libelle"].tostring(), labelveh=reader["libveh"].tostring()};      lecmb_statut.tag=lbl; } 

then inside lecmb_statut_selectedindexchanged:

lecmb_statut_selectedindexchanged (object sender, system.eventargs e) {     labeldto labeldto= ((dropdownlist)sender).tag labeldto ;     if (labeldto!=null)      {         ///here can use label , labelveh properties.       } } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -