DataGrid tips

xiaoxiao2021-03-06  52

// Add Delete Confirmation dialog:

PRIVATE VOID DATAGRID1_

Itemdatabase ()

{

Switch (E.Item.ItemType)

{

Case ListItemType.Item:

Case ListItemType.AlternatingItem:

Case ListItemType.editItem:

ImageButton BTN = (ImageButton) E.Item.FindControl ("btndelete");

Btn.attributes.add ("Onclick", "Return Confirm ('Do you determine whether this record?');");

Break;

}

}

Processing operation:

PRIVATE VOID DATAGRID1_ITEMCOMMAND ()

{

String c = e.commandname;

INT PermissionsID = (int) this.dataGrid1.datakeys [E.Item.ItemIndex]; // DatakeyField Value

Switch (c)

{

Case "delete":

// Perform a delete operation

Break;

}

}

There is also a good method:

DataGrid- "Properties Builder -" Column - "Add button column -" Delete - "Text (T) -> Add: in the text box:

Delete

Oh, you can /

OK!

// Re-page assignment:

Private void DataGrid1_itemdatabase ()

{

IF ((E.Item.ItemType == ListItemType.Item) || (E.Item.ItemType == ListItemType.alternatingItem))

{

//e.item represents a line

String imgurl =

String) DataBinder.eval (E.Item.DataItem, "ImageURL");

// Note this line, what type of "imageurl" field is turning to, otherwise an error

//e.item.cells[0].style.add("Font-weight "," bold ");

//e.item.cells[0].forecolor = system.drawing.color.red;

//e.item.backcolor = system.drawing.color.AliceBlue;

String s = E.Item.DataItem.toTostring ();

String ss = E.Item.cells [0] .TEXT;

INT SSS = E.Item.cells.count;

}

}

// Binding is the number of recalculated pages and the current page

Public void DataShowbind (Dataset DS)

{

THIS.DATAGRID1.DATASOURCE = DS;

IF (ds.tables.count> 0)

{

Int rowscount = ds.tables [0] .rows.count;

Double P = double.parse (RowsCount.toString ()) / 5.0;

// Note: Only double / double result is Double, int / int = int;

INT newPageCount = int.parse (Math.ceiling (p)); if (this.DataGrid1.currentpageIndex> newPageCount-1)

{

this.dataGrid1.currentpageindex -;

}

THIS.DATAGRID1.DATABIND ();

}

}

The incident of the control in the column is first reversed

DataGrid1_itemmnd

Event, but to judge CommandName

Private void TopicsGrid_

ItemCommand (e)

{

String btn = e.commandname;

INT i = 0;

Switch (btn)

{

Case "edit":

I = (int) this.topicsgrid.datakeys [E.Item.ItemIndex];

Break;

Case "delete":

I = (int) this.topicsgrid.datakeys [E.Item.ItemIndex];

Break;

}

}

Click on the link list

>>>>>>

<% # Databinder.eval (Container.DataItem, "Shares Name")%>

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

New Post(0)