当前位置:编程学习 > asp >>

ASP.NET简化编辑界面

简化用户操作介面,添加功能一般没法简化,但是如果是在GridView做显示,编辑,更新与删除,会让用户在编辑,需要点击编辑铵钮,再进行编辑,或是取消编辑。
为了解决这个问题,Insus.NET想到一些改进的方法。可以参考下面演示:

 
以下内容于2011-11-07 9:20添加:
上面实现,只是使用Table加上GridView来组合。
其中,Gridveiw直接使用ItemTemplate模版,省略了EditItemTemplate模版。事件也省略了OnRowEditing与OnRowCancelingEdit事件。
如下所示:

 
 
然后把EditItemTemplate的内容搬至ItemTemplate模版中,并替换。

 
完整代码参考如下:
  

<asp:Table ID="Table1" runat="server" CssClass="table" CellPadding="2" CellSpacing="0">
                <asp:TableHeaderRow Height="20" BackColor="#efebde" BorderWidth="1" BorderColor="#c0c0c0">
                    <asp:TableHeaderCell BackColor="#efebde" BorderWidth="1" BorderColor="#c0c0c0">
                    Chinese Name
                    </asp:TableHeaderCell>
                    <asp:TableHeaderCell BackColor="#efebde" BorderWidth="1" BorderColor="#c0c0c0" Width="50%">
                    English Name
                    </asp:TableHeaderCell>
                    <asp:TableHeaderCell BackColor="#efebde" BorderWidth="1" BorderColor="#c0c0c0" Width="10%">
                    Edit
                    </asp:TableHeaderCell>
                </asp:TableHeaderRow>
                <asp:TableRow Height="20">
                    <asp:TableCell BorderWidth="1" BorderColor="#c0c0c0">
                        <asp:TextBox ID="txt_CName" runat="Server" />
                    </asp:TableCell>
                    <asp:TableCell BorderWidth="1" BorderColor="#c0c0c0">
                        <asp:TextBox ID="txt_EName" runat="Server" />
                    </asp:TableCell>
                    <asp:TableCell BorderWidth="1" BorderColor="#c0c0c0">
                        <asp:Button ID="ButtonInsert" Text="Insert" runat="Server" OnClick="ButtonInsert_Click" />
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
            <div style="margin-top: 3px; margin-bottom: 3px; padding: 3px;">
            </div>
            <asp:GridView ID="GvCutterType" runat="server" DataKeyNames="CutterTypeId" AutoGenerateColumns="false"
                CellPadding="2" CellSpacing="0" Width="100%" BorderWidth="0" BorderColor="#c0c0c0"
                OnRowDeleting="GvCutterType_OnDeleteCommand" OnRowUpdating="GvCutterType_OnUpdateCommand"              
                RowStyle-Height="20" ShowHeader="false">
                <Columns>
                    <asp:TemplateField>
                        <ItemStyle BorderWidth="1" BorderColor="#c0c0c0" />
                        <ItemTemplate>
                            <asp:TextBox ID="txtCName" runat="server" Text='<%# Eval("CName") %>'></asp:TextBox>
                        </ItemTemplate>                      
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemStyle BorderWidth="1" BorderColor="#c0c0c0" Width="50%" />
       &

补充:Web开发 , ASP.Net ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,