使用ComponentOne C1WebGrid控件「建议收藏」
作者:Sinory ComponentOne.Studio.Enterprise.2006中的(C1StudioAspNET2_T106)是著名的C1开发的针对ASP.NET2.0的一套控件库.为ASP.NET开发人员提供了功能丰富的Web开发组件。包括个表格,报表,图表,数据,用户界面和电子商务组件等支持.C1WebGrid是其中最基本的控件之一. 下面介绍它的具体应用方法: 添加引用:
<%
@ Register Assembly=“C1.Web.C1WebGrid.2“ Namespace=“C1.Web.C1WebGrid“ TagPrefix=“C1WebGrid“ %>
在网页中添加定义
< c1webgrid:c1webgrid id =”C1WGridResult” width =”100%” runat =”server” allowpaging =”True” allowsorting =”True” backcolor =”White” bordercolor =”#999999″ borderstyle =”Groove” borderwidth =”1px” cellpadding =”3″ groupindent =”” pagesize =”30″ allowcolsizing =”True” imagesortascending =”~/images/up.gif” imagesortdescending =”~/images/down.gif” onpageindexchanging =”C1WGridResult_PageIndexChanged” onsortingcommand =”C1WGridResult_SortingCommand” onitemdatabound =”C1WGridResult_ItemDataBound” onitemcreated =”C1WGridResult_ItemCreated” >
< footerstyle backcolor =”#CCCCCC” font-size =”9pt” font-bold =”False” font-italic =”False” font-overline =”False”
font-strikeout =”False” font-underline =”False” forecolor =”Black” />
< selecteditemstyle backcolor =”White” font-bold =”False” font-italic =”False” font-overline =”False”
font-strikeout =”False” font-underline =”False” forecolor =”White” />
< itemstyle backcolor =”WhiteSmoke” font-size =”9pt” font-bold =”False” font-italic =”False” font-overline =”False”
font-strikeout =”False” font-underline =”False” forecolor =”Black” horizontalalign =”Left” bordercolor =”#E0E0E0″ borderstyle =”Dashed” borderwidth =”1px” wrap =”False” />
< groupingstyle backcolor =”White” bordercolor =”Silver” borderwidth =”1px” wrap =”False” ></ groupingstyle >
< pagerstyle backcolor =”#DEDBDE” font-bold =”False” font-italic =”False” font-overline =”False”
font-strikeout =”False” font-underline =”False” forecolor =”Black” horizontalalign =”Left” mode =”NumericPages” borderstyle =”Groove” borderwidth =”1px” />
< headerstyle backcolor =”#999999″ font-size =”9pt” height =”25px” font-bold =”True” font-italic =”False” font-overline =”False”
font-strikeout =”False” font-underline =”False” forecolor =”Black” cssclass =”C1WGridCss” wrap =”False” />
< alternatingitemstyle backcolor =”LightGray” font-bold =”False” font-italic =”False” font-overline =”False”
font-strikeout =”False” font-underline =”False” bordercolor =”#404040″ borderstyle =”Dotted” borderwidth =”1px” />
</ c1webgrid:c1webgrid >
下面介绍几个基本的属性: allowpaging=”True” ——是否允许分页 allowsorting=”True”——是否允许排序 pagesize=”30″ ——页面包含的记录的条数 allowcolsizing=”True”——是否允许通过拖动改变列宽 imagesortascending=”~/images/arrow_up.gif”,imagesortdescending=”~/images/arrow_down.gif” ——指定排序时在列首显示的图片 onpageindexchanging=”C1WGridResult_PageIndexChanged” ——关联到分页处理函数onsortingcommand=”C1WGridResult_SortingCommand” ——关联到排序函数 onitemdatabound=”C1WGridResult_ItemDataBound” ——关联到数据绑定处理函数 onitemcreated=”C1WGridResult_ItemCreated”——在每个Item创建后触发
onsortingcommand——处理排序示例
//注意在设置WebGrid列时要指定每个列自己的SortExpression值,这个函数才能生效,该值一般为该列绑定到的列的列名。
protected void C1WGridResult_SortingCommand( object sender, C1.Web.C1WebGrid.C1SortingCommandEventArgs e)
{
//用来记录排序方式
String SortDirection = “ASC“;
//用来记录排序表达式
String SortExpression = e.SortExpression.ToString();//得到当前选择排序的列的排序表达式
//如果为空则直接返回
if (SortExpression == “”) return;
try
{
//如果不为null
if (C1WGridResult.Attributes[“SortExpression“] != null)
{
if (SortExpression == C1WGridResult.Attributes[“SortExpression“].ToString())
{
SortDirection = (C1WGridResult.Attributes[“SortDirection“].ToString() == SortDirection ? “DESC“ : “ASC“);//选择相反的排序方式
}
}
else
{
SortDirection = “DESC“;//
}
//将上面得到的值附给WebGrid,然后重新绑定数据
C1WGridResult.Attributes[“SortExpression“] = SortExpression;
C1WGridResult.Attributes[“SortDirection“] = SortDirection;
BindC1WGridResult();
}
catch (Exception ex)
{
}
}
// 这里代码的目的是为了使不能排序的列,如模板列,的列
// 头显示为文字形式而不是连接形式,因为在这个控件中,
// 即使把列的SortExpression设置为空也还是会在列头处
// 显示为一个linkbutton(和GridView不同)
protected void C1WGridResult_ItemCreated( object sender, C1.Web.C1WebGrid.C1ItemEventArgs e)
{
try
{
if (e.Item.ItemType == C1.Web.C1WebGrid.C1ListItemType.Header)
{
TableCellCollection tcc = e.Item.Cells;
//这里假设第一列为模板列
tcc.RemoveAt(0);
tcc.Add(new TableHeaderCell());
tcc[0].Text = “选择“;//设置列头文字
}
}
catch
{ }
}
另外还可以通如下设置使相同内容的两个Cell合并 C1WGridResult.Columns[2].RowMerge = C1.Web.C1WebGrid.RowMergeEnum.Free;//合并相同
转载于:https://www.cnblogs.com/hjzhang/archive/2006/09/09/2043597.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/185448.html原文链接:https://javaforall.cn
相关文章
- pytorch的安装及其在pycharm中的使用「建议收藏」
- oidc auth2.0_使用Spring Security 5.0和OIDC轻松构建身份验证「建议收藏」
- 树莓派命令连接wifi_使用命令行设置树莓派的wifi网络「建议收藏」
- MATLAB中神经网络工具箱的使用「建议收藏」
- Hibernate二级缓存的使用「建议收藏」
- 使用IntelliJ IDEA 配置Maven(入门)「建议收藏」
- Nginx日志管理——了解Nginx日志选项配置以及自定义日志格式使用「建议收藏」
- RAPIDxml的使用「建议收藏」
- CreateMutex WaitForSingleObject ReleaseMutex使用「建议收藏」
- opencv中cvCircle的使用方法「建议收藏」
- ASP.Net中menu控件使用「建议收藏」
- vue中keep-alive、activated的探讨和使用「建议收藏」
- 渗透测试神器Nessus使用教程「建议收藏」
- java rpm卸载_使用RPM卸载软件「建议收藏」
- jupyter notebook的链接密码 token查询 以及 pycharm 如何使用 jupyter notebook「建议收藏」
- GridView多层嵌套和折叠与展开(修改适合自己使用)