ItemDatabase takes out the data content within DataGrid

zhaozj2021-02-16  154

This example is to determine whether a line should be highlighted content // Data bonding private void DataGrid1_ItemDataBound (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {if (e.Item.ItemType The database fields HighlightListing == ListItemType.Item || E.Item.itemType == ListItemType.alternatingItem) {

/ / Search according to the corresponding DataKeys to search the data source itemlistDataTable if (DataGrid1.DataKeys [E.Item.ItemIndex]) ["HighlightListing"]. TOSTRING () == "1") {E.ITEM. ControlStyle.backcolor = system.drawing.color.fromargb (255, 255, 156);}}}

// Data source declaration must be some modified protected system.data.dataable itemlistDataTable;

// add a data source to give additional primary key System.Data.DataColumn [] ColumnsArry = {ItemListDataTable.Columns [ "ID"]}; ItemListDataTable.PrimaryKey = ColumnsArry; DataGrid1.DataSource = ItemListDataTable; DataGrid1.DataBind ();

转载请注明原文地址:https://www.9cbs.com/read-7876.html

New Post(0)