Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 6th, 2012  |  syntax: None  |  size: 2.88 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Getting Value instead of Text from ListItem in ListBox
  2. protected void btnPrasaj_Click(object sender, EventArgs e)
  3. {
  4.     List<ListItem> lista = new List<ListItem>();
  5.     string prasanje = null;
  6.     Application.Lock();
  7.     if (Application["prasanja"] == null) // za prvpat se postavuva prasanje
  8.     {
  9.         prasanje = txtNaslov.Text + "nnn" + txtPrasanje.Text;
  10.         lista.Add(new ListItem(prasanje, ddltema.SelectedIndex.ToString()));
  11.         lstProblemPrasanje.DataSource = lista;
  12.         lstProblemPrasanje.DataTextField = "Text";
  13.         lstProblemPrasanje.DataValueField = "Value";
  14.         lstProblemPrasanje.DataBind();
  15.         Application["prasanja"] = lista;
  16.     }
  17.     else
  18.     {
  19.         lista=(List<ListItem>)Application["prasanja"];
  20.         prasanje = txtNaslov.Text + "nnn" + txtPrasanje.Text;
  21.         lista.Add(new ListItem(prasanje, ddltema.SelectedIndex.ToString()));
  22.         lstProblemPrasanje.DataSource = lista;
  23.         lstProblemPrasanje.DataTextField = "Text";
  24.         lstProblemPrasanje.DataValueField = "Value";
  25.         lstProblemPrasanje.DataBind();
  26.         Application["prasanja"] = lista;
  27.     }
  28.     Application.UnLock();
  29. }
  30.        
  31. lstProblemPrasanje.DataTextField = "Text";
  32. lstProblemPrasanje.DataValueField = "Value";
  33.        
  34. protected void btnPrasaj_Click(object sender, EventArgs e)
  35. {
  36.     List<ListItem> lista = new List<ListItem>();
  37.     string prasanje = null;
  38.     Application.Lock();
  39.     if (Application["prasanja"] == null) // za prvpat se postavuva prasanje
  40.     {
  41.         prasanje = txtNaslov.Text + "nnn" + txtPrasanje.Text;
  42.         lista.Add(new ListItem(prasanje, ddltema.SelectedIndex.ToString()));
  43.         lstProblemPrasanje.DataSource = lista;
  44.         //lstProblemPrasanje.DataTextField = "Text";
  45.         //lstProblemPrasanje.DataValueField = "Value";
  46.         lstProblemPrasanje.DataBind();
  47.         Application["prasanja"] = lista;
  48.     }
  49.     else
  50.     {
  51.         lista=(List<ListItem>)Application["prasanja"];
  52.         prasanje = txtNaslov.Text + "nnn" + txtPrasanje.Text;
  53.         lista.Add(new ListItem(prasanje, ddltema.SelectedIndex.ToString()));
  54.         lstProblemPrasanje.DataSource = lista;
  55.         //lstProblemPrasanje.DataTextField = "Text";
  56.         //lstProblemPrasanje.DataValueField = "Value";
  57.         lstProblemPrasanje.DataBind();
  58.         Application["prasanja"] = lista;
  59.     }
  60.     Application.UnLock();
  61. }
  62.        
  63. protected void btnPrasaj_Click(object sender, EventArgs e)
  64. {
  65.     string key = "prasanja";
  66.     List<ListItem> lista = new List<ListItem>();
  67.     string prasanje = null;
  68.     Application.Lock();
  69.     if (Application[key] != null) // za prvpat se postavuva prasanje
  70.     {
  71.         lista = (List<ListItem>)Application[key];
  72.     }
  73.  
  74.     prasanje = txtNaslov.Text + "nnn" + txtPrasanje.Text;
  75.     lista.Add(new ListItem(prasanje, ddltema.SelectedIndex.ToString()));
  76.     lstProblemPrasanje.DataSource = lista;
  77.     lstProblemPrasanje.DataBind();
  78.     Application[key] = lista;
  79.     Application.UnLock();
  80. }