J
J
When a button is clicked, I want to populate multiple ddl's and under
certain circumstances I want to set the SelectedValue. I've tried different
variations of this:
protected void btnImport_Click(object sender, EventArgs e)
{
[snip]
int tblcols = dsCsv.Tables["csv"].Columns.Count;
for(int i=0; i<tblcols; i++)
{
ListItem liItem = new ListItem();
liItem.Text = dsCsv.Tables["csv"].Columns.ToString();
liItem.Value = dsCsv.Tables["csv"].Columns.ToString();
ddlAddress.Items.Add(liItem);
ddlOrganization.Items.Add(liItem);
if (liItem.Text.ToLower().IndexOf("company") >=0)
{
ddlOrganization.Items.FindByText(liItem.Text).Selected = true;
}
}
}
This doesn't work. Although items were added, the code won't recognize
these items until the entire btnImport_Click is finished. How can I
accomplish this?
Thanks.
certain circumstances I want to set the SelectedValue. I've tried different
variations of this:
protected void btnImport_Click(object sender, EventArgs e)
{
[snip]
int tblcols = dsCsv.Tables["csv"].Columns.Count;
for(int i=0; i<tblcols; i++)
{
ListItem liItem = new ListItem();
liItem.Text = dsCsv.Tables["csv"].Columns.ToString();
liItem.Value = dsCsv.Tables["csv"].Columns.ToString();
ddlAddress.Items.Add(liItem);
ddlOrganization.Items.Add(liItem);
if (liItem.Text.ToLower().IndexOf("company") >=0)
{
ddlOrganization.Items.FindByText(liItem.Text).Selected = true;
}
}
}
This doesn't work. Although items were added, the code won't recognize
these items until the entire btnImport_Click is finished. How can I
accomplish this?
Thanks.