0

我想在 aspx 页面上添加列,该值来自不同的查询,

这是我在 aspx 上的 datagridview :

                    <asp:Panel ID="pnlGrid" runat="server" align="center">
                        <asp:Label ID="lbldgTime" runat="server" Text=" "></asp:Label><br />
                        <asp:GridView ID="gvData" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                            EmptyDataText="No data available." CellPadding="4" DataKeyNames="PayId" Font-Size="13px"
                            ForeColor="Black" PageSize="20" Width="100%" Style="text-align: center">
                            <Columns>
                                <asp:TemplateField>
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <FooterStyle HorizontalAlign="Left" />
                                    <ItemTemplate>
                                        <asp:ImageButton ID="imgbtn" ImageUrl="~/Img/view.png" runat="server" Width="25"
                                            Height="25" OnClick="imgbtn_Click" />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                    </EditItemTemplate>
                                    <FooterTemplate>
                                    </FooterTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="No Account">
                                    <ItemStyle HorizontalAlign="Center" Width="100px" />
                                    <FooterStyle HorizontalAlign="Left" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblNoaccount" runat="server" Text='<%# Bind("PayAccount") %>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                    </EditItemTemplate>
                                    <FooterTemplate>
                                    </FooterTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Customer Name">
                                    <ItemStyle HorizontalAlign="Center" Width="150px" />
                                    <FooterStyle HorizontalAlign="Left" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblCustName" runat="server" Text='<%# Bind("PayCustName") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Amount">
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <FooterStyle HorizontalAlign="Left" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblAmount" runat="server" Text='<%# Bind("PayAmount") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Amount Paid">
                                    <ItemStyle HorizontalAlign="Center" Width="40px" />
                                    <FooterStyle HorizontalAlign="Left" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblRefNo" runat="server" Text='<%# Bind("PayRefNo") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Response">
                                    <ItemStyle HorizontalAlign="Center" Width="70px" />
                                    <FooterStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblResponse" runat="server" Text='<%# Bind("PayResponse") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>


                            </Columns>

                        </asp:GridView>

场 :

 <asp:TemplateField HeaderText="Response">
                                    <ItemStyle HorizontalAlign="Center" Width="70px" />
                                    <FooterStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblResponse" runat="server" Text='<%# Bind("PayResponse") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>

该值来自填充数据网格时的不同查询,

这是我的数据网格背后的代码:

Sub FillData()
        Try
            Dim dt As New DataTable
            Me.lbleMessage.Text = ""
            If txtDate.Text = "__/__/____" Then
                txtDate.Text = ""
            End If

            If CPayment.SearchPayment(txtAccount.Text.Trim, txtCustName.Text.Trim, txtAmount.Text, txtAmountPaid.Text, dropResponse.SelectedValue.ToString, txtRefNo.Text.Trim, txtDate.Text) Then

                dt = CPayment.DT
            Else
                eMessage("System failure: ", CPayment.eMsg)
            End If
            Dim RC As Integer = dt.Rows.Count
            totalrows = RC
            If RC = 0 Then
                'dt.Rows.Add()
                dt.Clear()
                gvData.DataSource = dt.DefaultView
                gvData.DataBind()
                eMessage("", "There are no row to display.")

            Else
                gvData.DataSource = dt.DefaultView
                gvData.DataBind()
                gvData.BottomPagerRow.Visible = True
            End If
        Catch ex As Exception
            eMessage("Load Data failure: ", ex.ToString())
        End Try

    End Sub

这是响应字段的查询:

 Public Function Revstatus(ByVal PayRefNo As String) As Boolean
        Dim strsql As String = "  Select  COUNT(*) from payment(Pay) inner(Join) Reversal(Rev) on Pay.PayRefNo = Rev.PayRefNo where Pay.PayRefNo ='%" & PayResponse & "%'"
        Return runQuery(strsql)
    End Function

ByVal PayRefNo As String参数 来自

<asp:TemplateField HeaderText="Amount Paid">
                                        <ItemStyle HorizontalAlign="Center" Width="40px" />
                                        <FooterStyle HorizontalAlign="Left" />
                                        <ItemTemplate>
                                            <asp:Label ID="lblRefNo" runat="server" Text='<%# Bind("PayRefNo") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>

填充时是否可以在数据网格上输入差异查询?

4

1 回答 1

0

啊……终于我找到了路。

在 datagridview 行绑定上,我这样做了:

If e.Row.RowType = DataControlRowType.DataRow Then
            Dim RefNo As Label = CType(e.Row.FindControl("lblRefNo"), Label)
            If CPayment.Revstatus(RefNo.Text) Then
                CType(e.Row.FindControl("lblRevResp"), Label).Text = "Reversed"
            Else
                CType(e.Row.FindControl("lblRevResp"), Label).Text = "Paid"
            End If
        End If
于 2013-06-03T03:17:34.857 回答