I am pretty new in C# and .NET and I have the following problem.
In my code I have something like this:
Table table = new Table();
lstLabelType.SelectedIndexChanged += new System.EventHandler(SelectDocumentTypeChanged);
that is attaching an event handler to a dropdown element into a view.
So when the user change the chosen value into this dropdown the SelectDocumentTypeChanged() method is performed, this one:
private void SelectDocumentTypeChanged(object sender, EventArgs e)
{
Debug.WriteLine("SelectDocumentTypeChanged() STARTED");
SPWeb contextWeb = SPContext.Current.Web;
DropDownList listaTipiDocumenti = (DropDownList)sender;
tipoDocumentoSelezionato = listaTipiDocumenti.SelectedValue;
this.renderizzaEtichetteFacoltative(tipoDocumentoSelezionato, table);
string url = contextWeb.Url;
string link = url + "/ARXEIA WEBPART/Stampa Etichetta.aspx?IsDlg=1&postazione=" + macchina + "&tipoDoc=" + tipoDocumentoSelezionato;
SPUtility.Redirect(link, SPRedirectFlags.Default, Context);
}
Now I have a problem. I have to pass to this event handler method the Table table object created in my code because into this method I have to use it.
How can I correctly implement this behavior? How can I pass this Table table object to the SelectDocumentTypeChanged() method when it is automatically called when the user change the value in my dropdown?