English Sentence Loading...
英语句子加载中...
Tag: Gridview |
  • 1
预览模式: 普通 | 列表

gridview 编辑,删除,更新的用法

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewUp.aspx.cs" Inherits="gridview_GridViewUp" %>

<!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="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <table cellpadding="0" cellspacing="0" border="0" width="80%" style="font-size: 11px">
                <tr>
                    <td align="center">
                        <asp:GridView ID="GridView1" runat="server" Width="100%" CellPadding="4" ForeColor="#333333"
                            AutoGenerateColumns="False" AllowPaging="True" PageSize="12" OnRowCancelingEdit="GridView1_RowCancelingEdit"
                            OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowDeleting="GridView1_RowDeleting"
                            DataKeyNames="id,name" OnPageIndexChanging="GridView1_PageIndexChanging" DataMember="card,price" OnRowDataBound="GridView1_RowDataBound" GridLines="None">
                            <Columns>
                                <asp:BoundField HeaderText="身份证号" DataField="card" Visible=false />
                                <asp:BoundField HeaderText="编号" DataField="id" ReadOnly="True" />
                                <asp:BoundField DataField="name" HeaderText="姓名" ReadOnly="True" />
                                <asp:TemplateField HeaderText="身份证号">
                                    <ItemTemplate>
                                        <%# Eval("card") %>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TBCard" Text='<%# Eval("card") %>' runat="server" Width="140px" />
                                    </EditItemTemplate>
                                    <ItemStyle Width="150px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="学历">
                                    <ItemTemplate>
                                        <%# Eval("description")%>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:HiddenField ID="HDFXueli" runat="server" Value='<%# Eval("xueli") %>' />
                                        <asp:DropDownList ID="DDLXueli" runat="server" Width="90px" />
                                    </EditItemTemplate>
                                    <ItemStyle Width="100px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="价格">
                                    <ItemTemplate>
                                        <%# Eval("price") %>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TBPrice" Text='<%# Eval("price") %>' runat="server" Width="90px" />
                                    </EditItemTemplate>
                                    <ItemStyle Width="100px" />
                                </asp:TemplateField>
                                <asp:BoundField HeaderText="建立时间" DataField="createdate" ReadOnly="True" />
                                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" HeaderText="操作" />
                            </Columns>
                            <PagerSettings FirstPageText="" LastPageText="" NextPageText="" PreviousPageText="" />
                            <RowStyle Height="20px" BackColor="#F7F6F3" ForeColor="#333333" />
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#999999" />
                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        </asp:GridView>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>

GridViewUp.aspx.cs文件代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 gridview_GridViewUp : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GridViewBind();
        }
    }

查看更多...

Tags: Gridview

分类:ASP.net C# | 固定链接 | 评论: 19 | 引用: 0 | 查看次数: 36285

关于GridView分页页码的讨论

在GridView中实现分页的效果方法很简单,只需要在“GridView任务”对话框中进行设置就可以了。在“GridView任务”对话框中,选择“启用分页”命令,这样建立起简单的分页效果。

在使用“启用分页”命令的时候要注意两点。

(1) 是否允许分页

查看更多...

Tags: Gridview GridView分页 分页

分类:ASP.net C# | 固定链接 | 评论: 1 | 引用: 0 | 查看次数: 4365

分页与查询 关于Gridview

引用第三方控件
引入AspNetPager.dll分页文件添加到bin目录下

在引用页中注册
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

在引用页中应用控件
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" HorizontalAlign="center"          OnPageChanged="AspNetPager1_PageChanged"
         OnPageChanging="AspNetPager1_PageChanging" PageSize="15" Width="100%">
</webdiyer:AspNetPager>

查询控件如下:
<td style="height:100%; border: 1px solid #B5C3EF" valign="top" nowrap="">
  <table>
  <tr valign="top">
  <td>查询条件:
            <asp:DropDownList
                ID="ddlQueryType" runat="server" Width="83px">
                <asp:ListItem Value="StatutoryAgent" Selected="True">法人代表</asp:ListItem>
                <asp:ListItem Value="RegistCapital">注册资本</asp:ListItem>
                <asp:ListItem Value="SetupTime">注册时间</asp:ListItem>
           </asp:DropDownList>
            <asp:DropDownList ID="DDLFilter" runat="server" Width="51px">
                <asp:ListItem Value="like">包含</asp:ListItem>
                <asp:ListItem Value="&gt;">大于</asp:ListItem>
                <asp:ListItem Value="&lt;">小于</asp:ListItem>
                <asp:ListItem Value="=">等于</asp:ListItem>
            </asp:DropDownList>&nbsp;
         </td>
            <td><mc:DropDownCalendar ID="DDCSetupTime" runat="server"  BorderStyle="Inset" BorderWidth="1px">
                <WeekendDayStyle BackColor="#C0FFFF" ForeColor="Brown" />
                <TitleStyle BackColor="#C00000" ForeColor="White" />
                <DayHeaderStyle BackColor="#C0C0FF" />
                <DateStyle BackColor="#FFFFC0" />
            </mc:DropDownCalendar>
            </td>
  <td>&nbsp;&nbsp;<asp:TextBox ID="txtQueryValue" runat="server" CssClass="DownTextBox" Width="172px"></asp:TextBox></td>
  <td><asp:Button ID="btnSearch" runat="server" CssClass="blueButtonCss" Text="查 询" Width="61px" OnClick="btnSearch_Click"  /></td>
  </tr>
  </table>
  </td>

查看更多...

Tags: 分页与查询 Gridview

分类:ASP.net C# | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 1806
  • 1