RowDataBound'不是...的成员。错误 [英] RowDataBound' is not a member of... Error

查看:72
本文介绍了RowDataBound'不是...的成员。错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想在DataBound GridView的底部添加一个总计。我最近问过如何在这里实现这一点,我得到了我需要的帮助。



遵循答案中给出的其中一个教程。我现在有一个错误,每次页面尝试加载。



我收到的错误是... 编译器错误消息:BC30456:'grvAgentStats_RowDataBound '不是'ASP.stats_aspx'的成员。



我不太清楚为什么我收到这个并且我发布了代码对于ASP.net页面和VB.Net代码隐藏。



ASP.NetStats.aspx

Hi,

I am trying to add a total to the bottom of a DataBound GridView. I recently asked how to acheive this on here and I got the help I needed.

After following one of the tutorials that were given in the answer. I now have an error, everytime the page try's to load.

The error I am receiving is... "Compiler Error Message: BC30456: 'grvAgentStats_RowDataBound' is not a member of 'ASP.stats_aspx'."

I'm not too sure why I am receiving this and I have posted the code for both the ASP.net page and the VB.Net Code-behind.

ASP.Net "Stats.aspx"

<asp:Button ID="btnView" runat="server" Text="View" cssClass="btnASView" /><br /><br />
    <asp:GridView ID="grvAgentStats" runat="server" AutoGenerateColumns="False" CellPadding="4"

        ForeColor="#333333" GridLines="None" Style="font-size: 12px" Width="500px" ShowFooter="True"

        OnRowDataBound="grvAgentStats_RowDataBound">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:BoundField DataField="Result" HeaderText="Result" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Left" />
            <asp:TemplateField HeaderText="Amount">
                <ItemTemplate>
                    <asp:Label ID="lblAmount" runat="server" Text='<%# Eval("Amount") %>' />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Label ID="lblTotalAmount" runat="server" />
                </FooterTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="At" HeaderText="@" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Left" />
            <asp:BoundField DataField="Fee" HeaderText="Fee" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Left" />
            <asp:BoundField DataField="Equals" HeaderText="=" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Left" />
            <asp:TemplateField HeaderText="Total">
                <ItemTemplate>
                    <asp:Label ID="lblTotal" runat="server" Text='<%# Eval("Total") %>' />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Label ID="lblTotalFee" runat="server" />
                </FooterTemplate>
            </asp:TemplateField>
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>





Stats.aspx代码隐藏



"Stats.aspx" Code-Behind

Private Sub DatabindResults()
        Dim SQLconn As SqlConnection
        Dim SQLComm As SqlCommand
        Dim SQLDa As SqlDataAdapter
        Dim SQLDt As DataTable
        Dim ADUsername As String = Session.Item("txtUsername")

        Dim Date1 As String = ddlDates.SelectedValue
        Dim ClientName As String = ddlClient.SelectedValue

        SQLconn = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)

        SQLComm = New SqlCommand("prcHHGenAgentStats_New", SQLconn)
        SQLComm.CommandType = CommandType.StoredProcedure
        SQLComm.Parameters.AddWithValue("@Month", 8)
        SQLComm.Parameters.AddWithValue("@ADUserName", ADUsername)
        SQLComm.Parameters.AddWithValue("@ClientName", "Client")

        SQLDa = New SqlDataAdapter(SQLComm)
        SQLDt = New DataTable()

        SQLDa.Fill(SQLDt)
        grvAgentStats.DataSource = SQLDt
        grvAgentStats.DataBind()
    End Sub

    Private Sub btnView_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnView.Click
        DatabindResults()
    End Sub

    Private Sub grvAgentStats_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grvAgentStats.RowDataBound
        Dim TotalAmount As Decimal
        Dim TotalFee As Decimal
        If e.Row.RowType = DataControlRowType.DataRow Then

            Dim lblAmount As Label = e.Row.FindControl("lblAmount")
            Dim lblTotal As Label = e.Row.FindControl("lblTotal")

            Dim Amount As Decimal = Decimal.Parse(lblAmount.Text)
            Dim Total As Decimal = Decimal.Parse(lblTotal.Text)

            TotalAmount += Amount
            TotalFee += Total

            If e.Row.RowType = DataControlRowType.Footer Then
                Dim lblTotalPrice As Label = DirectCast(e.Row.FindControl("lblAmount"), Label)
                Dim lblTotalUnitsInStock As Label = DirectCast(e.Row.FindControl("lblTotal"), Label)

                lblTotalPrice.Text = TotalAmount.ToString()
                lblTotalUnitsInStock.Text = TotalFee.ToString()

            End If

        End If
    End Sub





有关此问题的任何帮助一个人将非常感激,因为它现在真的开始让我感到麻烦。



PS - 我在这里和谷歌搜索了大约一个小时,我打赌有人发现了一些可以帮助我的东西哈哈!



谢谢,

JammoD



Any help on this one will be greatly appreciated as it's really starting to bug me now loll.

P.S - I've searched for about an hour on both here and google, and I bet someone find something that will help me lol!!

Thanks,
JammoD

推荐答案

看起来Visual Studio很混乱。您提到的事件确实存在于代码中。你可以做的是尝试重新启动Visual Studio并运行。如果这没有帮助,请尝试清除位于
It looks as if Visual Studio is confused. The event you mentioned, does exist in the code. What you can do is try restarting Visual Studio and running. If that does not help, try cleaning out the temporary asp.net websites folder located at
引用:

C:\ Windows \ Microsoft \ Framework \ {version} \Temporary ASP.NET Files

C:\Windows\Microsoft.NET\Framework\{version}\Temporary ASP.NET Files



我知道这听起来很愚蠢,但有时候它确实很有效。如果您在不同目录中安装了Windows,请确保替换驱动器号。并且还将{version}占位符替换为您正在开发的框架版本。您可以浏览到该目录并执行此操作:)



如果有帮助,请告诉我。如果没有,我会相应地修改答案。


I know it sounds stupid but sometimes it does work perfectly. If you have windows installed in different directory, then make sure that you replace the drive letter. And also replace the {version} placeholder with the framework version you are developing. You can just browse to that directory and do it :)

Do let me know if this helps. If not, I will modify the answer accordingly.


嗨朋友们,



我也是同样的代词
更改后发生的错误




方法'受保护的子GridmailDetails_RowDataBound(发件人为对象,e为System.Web.UI.WebControls.GridViewCommandEventArgs)'无法处理事件'Public Event RowDataBound(sender As Object,e As System.Web.UI.WebControls.GridViewRowEventArgs)'因为它们没有兼容的签名



分享我的知识



问候,

Velsamy A
Hi Friends,

I am also acing same pronlem
after changes the error occured like this

Method 'Protected Sub GridmailDetails_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs)' cannot handle event 'Public Event RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs)' because they do not have a compatible signature

Share me our knowledge

Regards,
Velsamy A


这篇关于RowDataBound'不是...的成员。错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆