GridView常用的几个技巧
2006-07-22 09:14
387 查看
[ 2006-07-18 23:06:17 | 作者: Clingingboy ]
: | |
1.格式化
1.1根据字段格式化
void productsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// determine the value of the UnitsInStock field
int unitsInStock = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "UnitsInStock"));
if (unitsInStock == 0)
// color the background of the row yellow
e.Row.BackColor = Color.Yellow;
}
}
1.2定制外观.
GridView本身内制很多皮肤,你也可以在主题里自定义皮肤,然后再把皮肤导入
<%@ Page Language="C#" StyleSheetTheme="GridViewTheme" %>
接着再选自动套用格式,则出现你自己定义的样式
2.编辑
当你编辑时想使用web控件时,你必须先将字段转化为模板.还可以对字段的输入进行验证.同时为保持界面美观,你还可以设置控件的外观
3.删除
在删除之前先弹出确认窗口,不可以用默认的删除按钮,需用下面代码
<asp:LinkButton ID="LinkButton1" Runat="server" OnClientClick="return confirm('Are you sure you want to delete this record?');"
CommandName="Delete">Delete Order Line Item</asp:LinkButton>
4.显示图片
使用ImageField在控件中直接显示图片
<asp:ImageField DataImageUrlField="PictureURL"></asp:ImageField>
其实很多东西跟DataGrid差不多的.大家可以看微软的例子
下载例子
上面代码的例子全带有教程,不过是E文的,但大家只看代码多都少少会看的懂的,例子在哪呢.就在你的msdn帮助文件里.自己去找吧
相关文章推荐
- Java数据库编程中的几个常用技巧
- Java数据库编程中的几个常用技巧
- php常用几个技巧
- 常用且老记不住的几个ORACLE技巧
- GridView常用操作与技巧---格式化突出显示、增删改、排序、编号、换行、对话框、翻页、求和等
- ASP.NET中GridView控件常用技巧
- jsf几个常用取值方法和技巧总结
- 用javascript操纵GridView中CheckBox的两个常用技巧
- 用javascript操纵GridView中CheckBox的两个常用技巧
- C#中gridView常用属性和技巧介绍
- 【转】Live Writer几个常用技巧
- Javascript中常用的几个技巧
- 几个常用经典的css技巧
- 用javascript操纵GridView中CheckBox的两个常用技巧
- Java数据库编程中的几个常用技巧
- Gridview常用技巧
- GridView的几个小技巧
- linux中常用的几个命令技巧
- Android之编译打包apk时几个常用的技巧
- 【淘宝SEO】实践经验总结几个常用的论坛推广技巧