开发者

Is it possible to bind gridview with multiple table data at design time

How can i bind multiple table data to grid view while in design mode.

This is my design

  <asp:GridView ID="grdACH" runat="server" AutoGenerateColumns="False" BackColor="White"
            BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" Cell开发者_运维百科Padding="4" ForeColor="Black"
            GridLines="Vertical" Style="left: 121px; position: absolute; top: 133px">
            <Columns>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <asp:CheckBox ID="CheckAll" runat="server" onclick="return check_uncheck (this );" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="ID" runat="server" Text='<%# DataBinder.Eval (Container.DataItem, "FedTaxID") %>'
                            Visible="false"></asp:Label>
                        <asp:CheckBox ID="checkRec" runat="server" onclick="return check_uncheck (this );" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="FedTaxID" SortExpression="FedTaxID">
                    <EditItemTemplate>
                        <asp:Label ID="lblFedTaxID" runat="server" Text='<%# Eval("FedTaxID") %>'></asp:Label>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblFedTaxID1" runat="server" Text='<%# Bind("FedTaxID") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="CompanyName" HeaderText="CompanyName"></asp:BoundField>
                <asp:BoundField DataField="EntryDescription" HeaderText="CompanyEntryDescription"></asp:BoundField>
                <asp:BoundField DataField="BankRoutingNumber" HeaderText="RoutingNumber"></asp:BoundField>
                <asp:BoundField DataField="Amount" HeaderText="Amount"></asp:BoundField>

This is from another table

    <asp:TemplateField HeaderText="TaxAuthority" SortExpression="Taxing_Auth_Name">
                    <EditItemTemplate>
                        <asp:Label ID="lblTaxAuthority" runat="server" Text='<%# Eval("Taxing_Auth_Name") %>'></asp:Label>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblTaxAuthority" runat="server" Text='<%# Bind("Taxing_Auth_Name") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>


            </Columns>
            <RowStyle BackColor="#F7F7DE" />
            <FooterStyle BackColor="#CCCC99" />
            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
            <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>

But i am getting an error as DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Taxing_Auth_Name'.

So can any one tell what to do

My stored proc that executes for binding

  select c.fedtaxid,companyname,'comapany desc',c.entrydescription,
  c.BankRoutingNumber,
  g.Amount,g.TaxAuthority from tblcustomer c join (
  select swc.fedtaxid As FedTaxID,sum(amount)  Amount, taxing_auth_name TaxAuthority from tbl_employees_swc_grosswagedetails swc where wage_code='GRTT' and    taxing_auth_name='FED' and (empid,payperiodnumber,payyear)  in (select distinct  empid,PayPeriodID,payyear  from tblcpyresults cpyr where  cpyr.fedtaxid=swc.fedtaxid )   group by swc.fedtaxid) g on c.fedtaxid=g.fedtaxid;


In your store procedure you written this

 taxing_auth_name TaxAuthority 

So define your label with TaxAuthority this will resolve the issue..

Like follows

    <asp:TemplateField HeaderText="TaxAuthority" SortExpression="TaxAuthority">
                <EditItemTemplate>
                    <asp:Label ID="lblTaxAuthority" runat="server" Text='<%# Eval("TaxAuthority") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblTaxAuthority" runat="server" Text='<%# Bind("TaxAuthority") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜