ASP.NET 新手需要主/详细帮助。 (也有截图)
我正在学习基本的数据驱动 ASP.NET Web 表单设计。 我已经完成了表格的第一部分,但我不知道下一步该做什么。
请查看我迄今为止创建的屏幕截图:http://www.twitpic.com/2gnmr
我需要帮助了解在主列表中使用哪种 HTML 元素,以及该元素上的什么事件/触发器用于触发“获取此选定项目的子记录”序列?
另外,ListView 是呈现主列表的正确方法吗? 目前,我并不想提供任何编辑功能; 我想我稍后会谈到这一点。
我应该使用其他 ASP.NET 数据控件,而不是像我一样手动编码列表视图吗?
我不想在每个客户名称旁边看到实际的“选择”链接项(看起来很愚蠢)。 我希望客户名称成为要单击的链接。
因此,您可以在下面的代码中看到我有一个 ListView 来呈现 CustomersWithOpenOrders 列表。 但是,它只是一个静态列表,那么我如何使公司名称标签可单击,以及我还需要什么才能使其触发某些隐藏代码以获取子记录。 我已经有一个代码隐藏方法来将传入的 CustomerNumber 的子记录获取到 DataTable 中,并且我想我知道如何将其绑定到子记录的网格或列表视图,但我不知道如何传递CustomerNumber 从主ListView 到UI 表单的方法。
<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
<table cellpadding="2" border="0" ID="tbl1" runat="server">
<tr id="Tr1" runat="server" class="lvHeader">
<th id="Th1" runat="server">Customer</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr2" runat="server">
<td>
<asp:Label ID="label2" class="FirstLine" runat="server" Text='<%# Eval("company") %>' />
<br />
<div class="SecondLine">
<asp:Label ID="labelCustNo" runat="server" Text='<%# Eval("custno") %>'/>
<asp:Label runat="server" Text='Ph: '></asp:Label>
<asp:Label ID="label3" runat="server" Text='<% # Eval("phone") %>' />
</div>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
I'm just beinning basic data driven ASP.NET webforms design. I have the first part of a form working, but I don't know what to do next.
Please see this screenshot of what I have created so far: http://www.twitpic.com/2gnmr
I need help knowing what kind of HTML element to use in the master list, and what event/trigger on that element to use to fire off the "get child records for this selected item" sequence?
Also, is a ListView even the correct way to present the master list? At this time, I'm not trying to provide any editing features; I'll get to that later, I guess.
Should I use some other ASP.NET data control rather than hand-coding a listview like I am doing?
I don't want to see an actual "Select" link item beside each Customer Name (that looks goofy). I want the Customer Name to be the link to click on.
So, you can see in my code below that I have a ListView to present a list of CustomersWithOpenOrders. But, it's just a static list, so how do I make the Company Name label clickable, and what else will I need to make it fire back to some code-behind to fetch the child records. I already have a code-behind method to get child records for a passed-in CustomerNumber into a DataTable, and I think I would know how to bind that to a grid or listview for child records, but I do not know how to pass the CustomerNumber from the master ListView to the method from the UI form.
<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
<table cellpadding="2" border="0" ID="tbl1" runat="server">
<tr id="Tr1" runat="server" class="lvHeader">
<th id="Th1" runat="server">Customer</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr2" runat="server">
<td>
<asp:Label ID="label2" class="FirstLine" runat="server" Text='<%# Eval("company") %>' />
<br />
<div class="SecondLine">
<asp:Label ID="labelCustNo" runat="server" Text='<%# Eval("custno") %>'/>
<asp:Label runat="server" Text='Ph: '></asp:Label>
<asp:Label ID="label3" runat="server" Text='<% # Eval("phone") %>' />
</div>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我个人还没有发现ListView不能解决我的需求的情况。 如果您想创建客户选择样式列表,您可以使用链接按钮进行绑定。
然后您需要将事件绑定到 ListView.ItemCommand。
I personally haven't found a case where the ListView can't solve my needs. If you want to create a customer selection style list you can use a link button for binding.
Then you would need to bind the event to the ListView.ItemCommand.