.Net怎么实现网格嵌套

wubaiyong 2005-02-21 10:23:49
例如:

+服装类————————————————————parent row
1 西服-----------|
2 裙子 |--------------------------only child grid
3 牛仔裤---------|
+食品类————————————————————parent row
1 罐头-----------|
2 火腿 |--------------------------only child grid
3 方便面---------|
-日常用品类——————————————————parent row
-电器类————————————————————parent row

用datagrid怎么样实现上面的功能。请贴源码,谢谢!!!


selectcustomerstr = "select customerid,customer,customertype,linkman,telphone,fax,mobil,email from customer where userid='" & userid & "'"
selectorderstr = "select saleorderno,customerid,ordername,orderstate,creartday from saledetail"

Dim selectcustomeradap As New SqlDataAdapter(selectcustomerstr, con)
Dim selectorderadap As New SqlDataAdapter(selectorderstr, con)
Dim selectcustomerset As New DataSet

selectcustomeradap.Fill(selectcustomerset, "customer")
selectorderadap.Fill(selectcustomerset, "saledetail")

Dim pa As New DataColumn
Dim ch As New DataColumn

pa = selectcustomerset.Tables("customer").Columns("customerid")
ch = selectcustomerset.Tables("saledetail").Columns("customerid")

Dim myr As New DataRelation("myr", pa, ch)

selectcustomerset.Relations.Add(myr)

DataGrid1.SetDataBinding(selectcustomerset, "customer")

上面的代码是我自己写得,问题是only child grid都是"myr",我现在想要他显示子表中的字段
...全文
161 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wubaiyong 2005-02-21
  • 打赏
  • 举报
回复
请有源码的帖出来,谢谢了!!!感恩涕零呀!!!
amendajing 2005-02-21
  • 打赏
  • 举报
回复
可以用控件,实现起来就很简单了
yizhixiaozhu 2005-02-21
  • 打赏
  • 举报
回复
up
wubaiyong 2005-02-21
  • 打赏
  • 举报
回复
是windows界面 vb.net的代码
mac_shen 2005-02-21
  • 打赏
  • 举报
回复
datagrid嵌套不就可以了
我给你repeater嵌套的例子
a.aspx

<TABLE WIDTH="96%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<asp:repeater id="rpt_newsType" runat="server">
<ItemTemplate>
<TR>
<TD height="30">
<%#DataBinder.Eval(Container, "DataItem.cod_name")%>
<a name='<%#DataBinder.Eval(Container, "DataItem.cod_xm")%>'>
<asp:Label Runat="server" ID="lbl_newsType" text='<%#DataBinder.Eval(Container, "DataItem.cod_xm")%>' Visible="False">
</asp:Label>
</a>
</TD>
<TD align="right"><a href='newsByType.aspx?news_type=<%#DataBinder.Eval(Container, "DataItem.cod_xm")%>&news_typeText=<%#DataBinder.Eval(Container, "DataItem.cod_name").trim%>'><IMG src="image/bar-more.gif" border="0"></a></TD>
</TR>
<TR>
<TD height="4" colspan="2" bgColor="#f2f2f2"></TD>
</TR>
<TR>
<TD colspan="2" background="image/bar-linebg01.gif" height="105" valign="top">
<TABLE cellSpacing="0" cellPadding="1" width="96%" border="0">
<asp:repeater id="rpt_news" runat="server">
<ItemTemplate>
<tr height="21">
<td width="3%"><img src="image/item.gif"></td>
<td><a class='<%#DataBinder.Eval(Container, "DataItem.news_titleCss")%>' href='newsdetail.aspx?news_id=<%#DataBinder.Eval(Container, "DataItem.news_id")%>' target="_blank"><%#DataBinder.Eval(Container, "DataItem.news_title")%></a></td>
<td align="center" width="20%" nowrap><%#DataBinder.Eval(Container, "DataItem.input_dt","{0:d}")%></td>
</tr>
</ItemTemplate>
</asp:repeater>
</TABLE>
</TD>
</TR>
</ItemTemplate>
</asp:repeater>
</TABLE>

a.aspx.vb

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
rpt_newsType.DataSource = DAL.NewsType.GetHaveNews(SystemSetup.UnionCode.SchU)
rpt_newsType.DataBind()
End If
End Sub

Private Sub rpt_newsType_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rpt_newsType.ItemDataBound
If e.Item.ItemIndex > -1 Then
Dim lbl_newsType As Label = CType(e.Item.FindControl("lbl_newsType"), Label)
Dim rpt_news As Repeater = CType(e.Item.FindControl("rpt_news"), Repeater)

rpt_news.DataSource = GetDrsFromDt(News.GetByBelongType(SystemSetup.UnionCode.SchU, lbl_newsType.Text), "", "", 10)
rpt_news.DataBind()
End If
End Sub
wubaiyong 2005-02-21
  • 打赏
  • 举报
回复
请说详细一点,最好能帖代码
athossmth 2005-02-21
  • 打赏
  • 举报
回复
这个不难,两列,左边显示大小类别,右边同时放进 parent row和only child grid的内容,然后在item_databound中控制显示哪一个。
wubaiyong 2005-02-21
  • 打赏
  • 举报
回复
请说详细一点呀。我用的是vb.net。
uffeng 2005-02-21
  • 打赏
  • 举报
回复
这个 我负责项目才实现
必须用 模板
模板中放一个 span
span中 放一个 datagrid
hyl6688 2005-02-21
  • 打赏
  • 举报
回复
用模板列 在DataGrid中再放几个DataGrid

16,549

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧