数据查询和显示
来源:互联网 发布:微信导入数据库失败 编辑:程序博客网 时间:2024/05/21 08:49
GridView
用编码绑定数据源
this.gridview.dataSource=UserManager.GetAllUsers
this.gridview.DataBind();
---------------------------------------------------------------------------------------------------
GridView中有很多模板
TemplateFile 可以代替其他模板的功能
ButtonField 通过CommandName来设置命令的名字
它的好处是:
protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
int row = Convert.ToInt32( e.CommandArgument);
if(e.CommandName=="toUpper")
GridView1.Rows[row].Cells[1].Text = GridView1.Rows[row].Cells[1].Text.ToUpper();
if(e.CommandName=="toLower")
GridView1.Rows[row].Cells[1].Text = GridView1.Rows[row].Cells[1].Text.ToLower();
}
RowCommand事件:当GridView内生成事件时触发
通过CommandName找到对应按钮要执行的事件
---------------------------------------------------------------------------------------------------------
RowDataBound在对行进行数据绑定后触发的事件
可以做特效
如:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton button = e.Row.Cells[17].FindControl("LinkButton1") as LinkButton;
button.CommandArgument = e.Row.RowIndex.ToString();//哪一行的LinkButton
e.Row.Attributes.Add("onmouseover", "this.className='overrow'");
if (e.Row.RowIndex % 2 == 0)
{
e.Row.Attributes.Add("class", "even");
e.Row.Attributes.Add("onmouseout", "this.className='even'");
}
else
{
e.Row.CssClass = "odd";
e.Row.Attributes.Add("onmouseout", "this.className='odd'");
}
}
}
- 数据查询和显示
- easyui datagrid 数据的显示和查询
- JTABLE查询数据显示
- 如何使用 ASP.NET查询和显示 Excel 数据
- 如何使用 ASP.NET查询和显示 Excel 数据
- Flex调用WebService进行数据查询和显示(调整)
- PL/SQL 查询和显示的数据 中文乱码
- 用Bmob实现用户数据添加和查询显示
- 网站的搭建和对数据库存的查询显示和数据添加
- sqlplus 显示查询所有数据
- Sql查询数据分页显示
- mongdb查询显示全部数据
- 数据查询的排列显示
- 一条SQL查询单个数据和多个数据,并能在分页上显示
- 数据查询之子查询和嵌套查询
- 如何使用 ASP.NET、ADO.NET 和 Visual C# .NET 查询和显示 Excel 数据
- 如何使用 ASP.NET、ADO.NET 和 Visual C# .NET 查询和显示 Excel 数据
- 如何使用 ASP.NET、ADO.NET 和 Visual C# .NET 查询和显示 Excel 数据
- Html代码编写技巧二
- DIV滑动效果
- 关于数据控件的嵌套问题
- 急,一个想学ASP.NET的菜鸟。
- 排序算法
- 数据查询和显示
- FAT12文件系统基本格式
- 反汇编深入分析函数调用
- 程序员30岁以后的发展迷途
- 应聘中遇到的bom
- 雨,疯狂地下
- 字符串拷贝函数使用注意事项
- SD&MM正向流程
- Java调用批处理或可执行文件