I have implented a drop down list and I want to populate the data table according to the selected value in the drop down list. But currently I am unable to display the selectedIndexChanged. Please assist.
protected void ddlitem_SelectedIndexChanged(object sender, EventArgs e)
{
DataTable result = new DataTable();
result.Columns.Add("Supplier");
result.Columns.Add("Country");
result.Columns.Add("Partnership Duration");
result.Columns.Add("Partnership Type");
int intMemberIndex = 0;
try
{
foreach (SPListItem objtestListItem in objtestList.Items)
{
string SupplierName = objtestListItem["Supplier"].ToString();
string Country = objtestListItem["Country"].ToString();
string PD = objtestListItem["Partnership Duration"].ToString();
string PT = objtestListItem["Partnership Type"].ToString();
intMemberIndex = objtestListItem.ID;
for (int i = 0; i < ddlitem.Items.Count; i++)
{
if (ddlitem.Items[i].Text.Equals(SupplierName))
{
result.Rows.Add(SupplierName, Country, PD, PT);
}
}
} this.resultGrid.DataSource = result;
this.resultGrid.Visible = true;
this.resultGrid.DataBind();
}
catch (Exception ex)
{
lblTxt.Text = ex.Message;
}
}
}