ASP.NET MVC2 中的 GridView

发布于 2024-09-30 03:02:10 字数 6074 浏览 5 评论 0 原文

我需要使用 ASP.Net gridview 并在我的 asp.net mvc 内容视图中执行诸如排序分页和选择复选框之类的操作。我不知道该怎么办。我写了这样的东西:

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table runat="server" id="tbldealData" style="width: auto; height: auto">
                <tr>
                    <td>
                    <cc1:ExtendedGridView ID="ExtendedGridView1" runat="server" AutoGenerateColumns="false"
                            AllowFiltering="true">
                            <Columns>
                            <asp:TemplateField HeaderText="Wait For Payment From SAP">
                                <EditItemTemplate>
                                    <asp:CheckBox ID="chkWaitForSAP" runat="server" />
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox runat="server" ID="chkWaitForSAP" Checked="true" AutoPostBack="true"/>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Deal Number" SortExpression="DealNumber">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%= Html.LabelFor(model => model.DealNumber) %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%= Html.LabelFor(model => model.DealNumber) %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Cost Number" SortExpression="CostNumber">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox5" runat="server" Text='<%= Html.LabelFor(model => model.CostNumber) %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label5" runat="server" Text='<%= Html.LabelFor(model => model.CostNumber) %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Source System" SortExpression="SourceSystemName">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox6" runat="server" Text='<%= Html.LabelFor(model => model.SourceSystemName) %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label6" runat="server" Text='<%= Html.LabelFor(model => model.SourceSystemName) %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="CounterParty" SortExpression="CounterpartyName">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox7" runat="server" Text='<%= Html.LabelFor(model => model.CounterpartyName) %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label7" runat="server" Text='<%= Html.LabelFor(model => model.CounterpartyName) %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                     </Columns>
                        <AlternatingRowStyle BackColor="#E5E5E5" />
                        <PagerStyle ForeColor="Blue" />
                        <PagerTemplate>
                            <asp:LinkButton CommandName="Page" CommandArgument="First" ID="LinkButton1" runat="server"
                                Style="color: Blue">  
                                « First</asp:LinkButton>
                            <asp:LinkButton CommandName="Page" CommandArgument="Prev" ID="LinkButton2" runat="server"
                                Style="color: Blue"> < Prev</asp:LinkButton>
                            [<%= ExtendedGridView1.PageIndex * ExtendedGridView1.PageSize%>-<%= ExtendedGridView1.PageIndex * ExtendedGridView1.PageSize + ExtendedGridView1.PageSize - 1%>]
                            <asp:LinkButton CommandName="Page" CommandArgument="Next" ID="LinkButton3" runat="server"
                                Style="color: Blue">  
                                Next ></asp:LinkButton>
                            <asp:LinkButton CommandName="Page" CommandArgument="Last" ID="LinkButton4" runat="server"
                                Style="color: Blue">  
                                Last »</asp:LinkButton>
                        </PagerTemplate>
                        </cc1:ExtendedGridView>
                         </td>
                </tr>
                <tr>
                    <td>
                        <input type="submit" value="Save" />
                        <input type="reset" value="Cancel" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

但它并没有在我的渲染视图中向我展示任何东西。现在一片空白。请帮忙

I need to use ASP.Net gridview and do operations like sorting paging and selecting checkboxes in my asp.net mvc content view. I dont what to do. I've written something like this:

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table runat="server" id="tbldealData" style="width: auto; height: auto">
                <tr>
                    <td>
                    <cc1:ExtendedGridView ID="ExtendedGridView1" runat="server" AutoGenerateColumns="false"
                            AllowFiltering="true">
                            <Columns>
                            <asp:TemplateField HeaderText="Wait For Payment From SAP">
                                <EditItemTemplate>
                                    <asp:CheckBox ID="chkWaitForSAP" runat="server" />
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox runat="server" ID="chkWaitForSAP" Checked="true" AutoPostBack="true"/>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Deal Number" SortExpression="DealNumber">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%= Html.LabelFor(model => model.DealNumber) %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%= Html.LabelFor(model => model.DealNumber) %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Cost Number" SortExpression="CostNumber">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox5" runat="server" Text='<%= Html.LabelFor(model => model.CostNumber) %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label5" runat="server" Text='<%= Html.LabelFor(model => model.CostNumber) %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Source System" SortExpression="SourceSystemName">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox6" runat="server" Text='<%= Html.LabelFor(model => model.SourceSystemName) %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label6" runat="server" Text='<%= Html.LabelFor(model => model.SourceSystemName) %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="CounterParty" SortExpression="CounterpartyName">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox7" runat="server" Text='<%= Html.LabelFor(model => model.CounterpartyName) %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label7" runat="server" Text='<%= Html.LabelFor(model => model.CounterpartyName) %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                     </Columns>
                        <AlternatingRowStyle BackColor="#E5E5E5" />
                        <PagerStyle ForeColor="Blue" />
                        <PagerTemplate>
                            <asp:LinkButton CommandName="Page" CommandArgument="First" ID="LinkButton1" runat="server"
                                Style="color: Blue">  
                                « First</asp:LinkButton>
                            <asp:LinkButton CommandName="Page" CommandArgument="Prev" ID="LinkButton2" runat="server"
                                Style="color: Blue"> < Prev</asp:LinkButton>
                            [<%= ExtendedGridView1.PageIndex * ExtendedGridView1.PageSize%>-<%= ExtendedGridView1.PageIndex * ExtendedGridView1.PageSize + ExtendedGridView1.PageSize - 1%>]
                            <asp:LinkButton CommandName="Page" CommandArgument="Next" ID="LinkButton3" runat="server"
                                Style="color: Blue">  
                                Next ></asp:LinkButton>
                            <asp:LinkButton CommandName="Page" CommandArgument="Last" ID="LinkButton4" runat="server"
                                Style="color: Blue">  
                                Last »</asp:LinkButton>
                        </PagerTemplate>
                        </cc1:ExtendedGridView>
                         </td>
                </tr>
                <tr>
                    <td>
                        <input type="submit" value="Save" />
                        <input type="reset" value="Cancel" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

but it is not shwoing me any thing in my rendered view. Am blank now. Please help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

熟人话多 2024-10-07 03:02:10

尽管可以,但我不建议在 MVC 中使用 Web 控件。我建议使用客户端网格,或创建一个实现类似功能的 HTML 帮助程序。

如果您想要一个免费、优雅且易于实现的 MVC 网格,您可以查看 Telerik< /a>.在我看来,那里的电网是世界一流的。

Although you can, I don' recommend using web controls in MVC. I would recommend utilizing a client side grid, or creating a HTML helper that achieves similar functionality.

If you want a FREE, elegant, and easy to implement grid for MVC you can check out Telerik. There grid is world class, IMO.

找个人就嫁了吧 2024-10-07 03:02:10

如果您不反对下载 ASP.NET MVC 3 Beta,有一个名为 WebGrid 的新控件/帮助器,它可以完全满足您的需求。

写入/使用它 此处

If you're not adversed to downloading ASP.NET MVC 3 Beta, there is a new control/helper called WebGrid which will do exactly what you want.

Writeup/usage on it here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文