Extaspnet Gridpanel General Usage _ Practical skills

Source: Internet
Author: User
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
{
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.