Saturday, August 28, 2010

Populate drop down liast repeater

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
DropDownList dll = (DropDownList )e.Item.FindControl("ddOptions");
if (dll != null)
{
string ID = //Grab the id here
DataTable dt = // call the method from your Class library that returns a DataTable and pass the value of ID as the paramter

if (dt.Rows.Count > 0)
{
dll.DataSource = dt;
dll.DataTextField = "ColumnName";
dll.DataValueField = "ColumnName";
dll.DataBind();
}
}

}

}

No comments: