I have multiple dropdown & listbox in my webpage.
I am trying to get a list of CategoryID
from a lstCatID
listbox i am able to populate
Try to add Page.IsPostback on your Page_Load like
protected void Page_Load(object sender, EventArgs e)
{
// Do your API code here unless you want it to occur only the first
// time the page loads, in which case put it in the IF statement below.
if (!Page.IsPostBack)
{
}
}
Code:
protected void Button1_Click(object sender, EventArgs e)
{
string CatID = string.Empty;
foreach (ListItem li in lstCatID.Items)
{
if (li.Selected )
{
// TODO: Whatever you are doing with a selected item.
}
}
Response.Write(CatID);
}
Once i was facing the same problem and i made Postback mistake.
Hope it works.