ASP.net Gridview 使用指南
GridView使用详解
01 GridView无代码分页排序
02 GridView选中,编辑,取消,删除
03 GridView正反双向排序
04 GridView和下拉菜单DropDownList结合
05 GridView和CheckBox结合
06 鼠标移到GridView某一行时改变该行的背景色方法一
07 鼠标移到GridView某一行时改变该行的背景色方法二
08 GridView实现删除时弹出确认对话框
09 GridView实现自动编号
10 GridView实现自定义时间货币等字符串格式
11 GridView实现用“...”代替超长字符串
12 GridView一般换行与强制换行
13 GridView显示隐藏某一列
14 GridView弹出新页面/弹出新窗口
15 GridView固定表头(不用javascript只用CSS,2行代码,很好用)
16 GridView合并表头多重表头无错完美版(以合并3列3行举例)
17 GridView突出显示某一单元格(例如金额低于多少,分数不及格等)
18 GridView加入自动求和求平均值小计
19 GridView数据导入Excel/Excel数据读入GridView 1.GridView简单代码分页排序: 1.AllowSorting设为True,aspx代码中是AllowSorting="True"; 2.默认1页10条,如果要修改每页条数,修改PageSize即可,在aspx代码中是PageSize="12"。 3.默认的是单向排序的,右击GridView弹出“属性”,选择AllowSorting为True即可。 4.添加代码: protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; Bind(); } 2.GridView选中,编辑,取消,删除: 后台代码: using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { SqlConnection sqlcon; SqlCommand sqlcom; string strCon = "Data Source=(local);Database=数据库名;Uid=帐号;Pwd=密码"; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bind(); } } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; bind(); } //删除 protected void GridView1_RowDeleting(object sender,
相关文档:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="s ......
在使用asp.net编写webservice时,默认情况下是不支持session的,但我们可以把WebMethod的EnableSession选项设为true来显式的打开它,请看以下例子:
1 新建网站WebSite
2 新建web服务WebService.asmx,它具有以下两个方法:
[WebMethod(EnableSession = true)]
public string Login(string name)
{
  ......
//根据主键来删除表中的数据。
//删除
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
OleDbConnection sqlConnection = new OleDbConnection(GetConnection());
& ......
其实所谓的伪静态页面,就是指的URL重写.
1.首先在web.config里写
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
2.在web.config里添加以下节点
<httpHandlers>
< ......