Copy Code code as follows:
<ext:grid id= "Gridecuser" runat= "Server" enablecheckboxselect= "false" enablerownumber= "true"
title= "User Management" allowpaging= "True"
Onpageindexchange= "Gridecuser_pageindexchange" pagesize= "10"
Onrowdatabound= "Gridecuser_rowdatabound" datakeynames= "UserId" >
<Toolbars>
<ext:toolbar id= "Toolbar1" runat= "Server" >
<Items>
<ext:button id= "Btnaddecuser" runat= "Server" text= "Add" icon= "Add" >
</ext:Button>
<ext:toolbarseparator id= "ToolbarSeparator1" runat= "Server" >
</ext:ToolbarSeparator>
<ext:button id= "Btntohome" runat= "server" text= "Home" onclick= "Btntohome_click" icon= "House" >
</ext:Button>
</Items>
</ext:Toolbar>
</Toolbars>
<Columns>
<ext:boundfield headertext= "User ID" width= "50px" hidden= "true" datafield= "UserId" columnid= "UserId"/>
<ext:boundfield headertext= "name" width= "150px" expandunusedspace= "True" datafield= "FullName" columnid= "FullName"/ >
<ext:boundfield headertext= "Login username" width= "150px" datafield= "LoginName" columnid= "LoginName"/>
<ext:boundfield headertext= "user Group" width= "150px" columnid= "Rolesfullname" datafield= "Rolesfullname"/>
<ext:checkboxfield headertext= "User status" Width= "80px" columnid= "IsOpen" datafield= "IsOpen"/>
<ext:linkbuttonfield headertext= "" Width= "60px" columnid= "Modiuser" text= "Modify" commandname= "Modi"/>
<ext:linkbuttonfield headertext= "" "Width=" 60px "columnid=" Deluser "text=" delete "commandname=" Del "confirmicon=" Question "confirmtext=" confirm that you want to delete users? "Confirmtitle=" Yi Cai International "/>
</Columns>
</ext:Grid>
C # code:
Copy Code code as follows:
Data binding:
Description: The DataField name of the column will match the field name in the DataTable.
DataTable Userdt = Userbll.getecuserlist ();
Gridecuser.datasource = Userdt;
Gridecuser.databind ();
Code
Copy Code code as follows:
protected void Gridecuser_rowdatabound (object sender, Extaspnet.gridroweventargs e)
{
DataRow Dr = E.dataitem as DataRow;
if (Dr!= null)
{
BOOL IsOpen = Convert.toboolean (dr["IsOpen"]);
if (IsOpen) e.values[4] = "else e.values[4] = "}
The method of centering column contents in grid:
Copy Code code as follows:
<ext:boundfield headertext= "name" width= "150px" expandunusedspace= "True" datafield= "FullName" columnid= "FullName" dataformatstring= "<div style= ' text-align:center;width:100% ' >{0}</div>"/>
The grid's Rowcommand event gets the column value:
1: Set the line keyword in the datakeynames of grid, such as: datakeynames= "Userid,username"
2:
Code
Copy Code code as follows:
protected void Gridecuser_rowcommand (object sender, Extaspnet.gridcommandeventargs e)
{
if (E.commandname = = "Modi")//Modify
{
String DD = Gridecuser.datakeys[e.rowindex][0]. ToString ();
ExtAspNet.Alert.Show (DD);
}
else if (e.commandname = "Del")//delete
{
}
}