在 C# 中将数据从多个表 ASP.NET 添加到 GridView

Add Data to GridView from Multiple Tables ASP.NET in C#

我需要知道如何将网格视图与 2 table 绑定,我已经将其与 PostedVoucher table 绑定,但我需要从交易 [=21] 添加列 trans_name =] 我该怎么做???

html 代码:

                <asp:Label ID="debit" runat="server" Text='<%# (Eval("stat_flag").ToString() =="d" ) ? Eval("stat_amount"): "0" %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>

              <asp:TemplateField HeaderText="دائن">
            <ItemTemplate>
                <asp:Label ID="credit" runat="server" Text='<%# (Eval("stat_flag").ToString() =="c" ) ? Eval("stat_amount"): "0" %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
                                <asp:BoundField  DataField="stat_desc" 
                                HeaderText="البيان" ItemStyle-Font-Size="Small"/>

                            <asp:BoundField  DataField="serial" 
                             HeaderText=" رقم السند " ItemStyle-Font-Size="Small"/>

                              <asp:BoundField  DataField="stat_date" dataformatstring="{0:dd/MM/yyyy}"
                                HeaderText="التاريخ" ItemStyle-Font-Size="Small"/>

C# 代码:

   SqlParameter[] para = new SqlParameter[4];
   para[0] = new SqlParameter("@stat_sub_leger", ddlACCcode.SelectedValue);
    para[1] = new SqlParameter("@branch", DDLBranch.SelectedValue);
    para[2] = new SqlParameter("@from", db.getDate(txtFrom.Text));
    para[3] = new SqlParameter("@to", db.getDate(txtTo.Text));

    DataTable dtreport = db.SelectCmdText("Select * from PostedVoucher where stat_sub_leger = @stat_sub_leger 
             and branch=@branch and stat_date between @from and @to ORDER BY stat_date ", para);


    GridView1.DataSource = dtreport;
    GridView1.DataBind();

@FEBY 您可以编写查询以从您的 table 中获取组合值,然后将其绑定到您的网格