gridval.aspx

来自「关于ASP.NET制作程序模块」· ASPX 代码 · 共 69 行

ASPX
69
字号
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="gridval.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="server">
    <title>无标题页</title>
    <style type="text/css">
        .td
        {
            border-bottom:dotted 1px #dcdcdc;
            border-right:dotted 1px #dcdcdc;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table style="border:solid 1px green;width:40%">
            <tr>
                <td style="background-color:Green"><strong><span style="font-size: 14pt; color: #ffffff">验证GridView控件中编辑列的值</span></strong>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:GridView Width="100%" ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowDataBound="GridView1_RowDataBound" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" DataKeyNames="ProductID">
                        <Columns>  
                            <asp:BoundField  DataField="ProductName" ReadOnly="True" HeaderText="商品名称"/>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <table width="100%">
                                        <tr>
                                            <td align="left" width="60%" >数量</td>
                                        </tr>
                                    </table>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <table width="100%">
                                        <tr>
                                            <td width="20%"><%# Eval("UnitsInStock")%></td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <table>
                                        <tr>
                                            <td width="20%"><asp:TextBox runat="Server" ID="t1" Text='<%# Eval("UnitsInStock")%>' Width="90%"></asp:TextBox></td>
                                        </tr>
                                    </table>
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:CommandField ShowEditButton="True" HeaderText="操作" />
                        </Columns>
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <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" />
                    </asp:GridView>
                </td>
            </tr>
        </table> 
    
    </div>
    </form>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?