我需要知道如何将网格视图绑定到2个表,我已经将它与PostedVoucher表绑定,但我需要从事务表中添加列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();
答案 0 :(得分:0)
@FEBY您可以编写查询以从两个表中获取组合值,然后将其绑定到您的网格