我得到DataGrid
了从这个 DataGrid 中获取其数据的 ControlDataTable
我想将DropDownList
Control 与 DataTable 中的相关数据绑定
DropDownList commentDrop = (DropDownList)packageCommentDataGrid.FindControl("commentDrop");
commentDrop.DataSource = dt;
commentDrop.DataTextField = dt.Columns["CommentString"][0];
commentDrop.DataValueField = dt.Columns["CommentP"][0];
和 ItemDataBound 事件将是这样的:
protected void packageCommentDataGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType==ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
DropDownList commentDrop = (DropDownList)e.Item.FindControl("commentDrop");
}
}
谢谢,