html
 1<asp:datalist id="datalist1" Width="690px" BorderStyle="None" ShowFooter="False" GridLines="Both"
 2                    Runat="server">
 3                    <HeaderTemplate>
 4                        <table style="FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: white; FONT-FAMILY: 新細明體">
 5                            <tr>
 6                                <td style="WIDTH: 120px; TEXT-ALIGN: center">傳票單號</td>
 7                                <td style="WIDTH: 120px; TEXT-ALIGN: center">入帳日期</td>
 8                                <td style="WIDTH: 120px; TEXT-ALIGN: center">傳票狀態</td>
 9                                <td style="WIDTH: 120px; TEXT-ALIGN: right">本幣借方</td>
10                                <td style="WIDTH: 120px; TEXT-ALIGN: right">本幣貸方</td>
11                                <td style="WIDTH: 60px; TEXT-ALIGN: center">審核</td>
12                            </tr>
13                        </table>
14                    </HeaderTemplate>
15                    <AlternatingItemStyle BackColor="#DBC4C4"></AlternatingItemStyle>
16                    <ItemTemplate>
17                        <table style=" FONT-SIZE: 9pt;  FONT-FAMILY: 新細明體">
18                            <tr>
19                                <td style="WIDTH: 120px; TEXT-ALIGN: center ">
20                                    <asp:linkbutton ID="accno" Runat=server text='<%#databinder.eval(container.dataitem,"傳票單號") %>' CommandName="select" />
21                                </td>
22                                <td style="WIDTH: 120px; TEXT-ALIGN: center "><%# container.dataitem("入帳日期")%></td>
23                                <td style="WIDTH: 120px; TEXT-ALIGN: center; "><%# container.dataitem("傳票狀態")%></td>
24                                <td style="WIDTH: 120px; TEXT-ALIGN: right; "><%# container.dataitem("本幣借方")%></td>
25                                <td style="WIDTH: 120px; TEXT-ALIGN: right; "><%# container.dataitem("本幣貸方")%></td>
26                                <td style="WIDTH: 60px; TEXT-ALIGN: center; ">
27                                    <asp:CheckBox ID="cb" Runat=server Checked='<%# Databinder.eval(container.dataitem,"審核") %>' /></td>
28                            </tr>
29                            <tr>
30                                <td colspan="6">
31                                    <asp:DataGrid ID="Datagrid1" Runat="server" AutoGenerateColumns="False" Font-Name="新細明體" Font-Size="9pt"
32                                        GridLines="Both" BorderStyle="None">
33                                        <Columns>
34                                            <asp:BoundColumn DataField="seq" HeaderText="序" ItemStyle-Width="10px" ItemStyle-HorizontalAlign="center"></asp:BoundColumn>
35                                            <asp:BoundColumn DataField="acccode" HeaderText="科目" ItemStyle-Width="60px"></asp:BoundColumn>
36                                            <asp:BoundColumn DataField="accname" HeaderText="科目名稱" ItemStyle-Width="100px"></asp:BoundColumn>
37                                            <asp:BoundColumn DataField="remark" HeaderText="摘要" ItemStyle-Width="200px"></asp:BoundColumn>
38                                            <asp:BoundColumn DataField="ckind" HeaderText="幣別" ItemStyle-Width="40px" ></asp:BoundColumn>
39                                            <asp:BoundColumn DataField="cramt" HeaderText="原幣借方" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign=Right></asp:BoundColumn>
40                                            <asp:BoundColumn DataField="dramt" HeaderText="原幣貸方" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign=Right></asp:BoundColumn>
41                                            <asp:BoundColumn DataField="crate" HeaderText="匯率" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign=Right></asp:BoundColumn>
42                                            <asp:BoundColumn DataField="camt" HeaderText="本幣借方" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign=Right></asp:BoundColumn>
43                                            <asp:BoundColumn DataField="damt" HeaderText="本幣貸方" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign=Right></asp:BoundColumn>
44                                        </Columns>
45                                    </asp:DataGrid></td>
46                            </tr>
47                        </table>
48                    </ItemTemplate>
49                    <HeaderStyle BorderStyle="None" BackColor="#B58383"></HeaderStyle>
50                </asp:datalist>

Code:
page_load事件:
...
            datalist1.DataSource = dt
            datalist1.DataBind()
            datalist1.Visible = True

            Dim accno As String
            For inta = 0 To datalist1.Items.Count - 1
                accno = CType(datalist1.Items(inta).FindControl("accno"), LinkButton).Text
                Dim datagrid1 As DataGrid = CType(datalist1.Items(inta).FindControl("datagrid1"), DataGrid)
                ...
                datagrid1.DataSource = dt
                datagrid1.DataBind()
                datagrid1.Visible = False
            Next

datalist1_ItemCommand事件:
        Dim dg As DataGrid = CType(e.Item.FindControl("datagrid1"), DataGrid)
        If dg.Visible = True Then
            dg.Visible = False
        Else
            dg.Visible = True
        End If

posted on 2007-08-02 09:34  小哈  阅读(321)  评论(0编辑  收藏  举报