Web Analytics Made Easy -
StatCounter Weird BC30260 error - CodingForum


No announcement yet.

Weird BC30260 error

  • Filter
  • Time
  • Show
Clear All
new posts

  • Weird BC30260 error


    I'm building an application in VS 2005 that uses a dataset to display info with checkboxes which determine what data is displayed after a button click. I think I have something wrong with my code behind and logic, but I'm really stumped and would appreciate any hints/direction help.

    My code behind is:

    Imports System.Data
    Imports System.Configuration
    Imports System.Web.UI.WebControls
    Imports DataSet1TableAdapters

    Namespace DotNetTony

    Public Class storylist : Inherits System.Web.UI.Page

    Dim btnShow As Button
    Dim lblSelections As Label

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not IsPostBack Then
    btnShow.Attributes.Add("onClick", "javascript:return confirm('Are you sure you want to delete these rows?')")
    End If
    End Sub

    Sub BindTheData()
    Dim newsAdapter As New Orizonti_NukeNews_NewsTableAdapter
    GridView1.DataSource = newsAdapter.GetData()
    End Sub

    Sub ShowSelections(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim dgItem As DataGridItem
    Dim chkSelected As CheckBox
    Dim strTitle As String
    Dim strID As String
    Dim strSummary As String
    Dim strPostDate As String

    lblSelections.Text = "<br>Fooled Ya! The following rows were marked for deletion, "
    lblSelections.Text += "but not actually deleted:<br><br>"
    For Each dgItem In GridView1.Items
    chkSelected = GridView1.FindControl("chkSelection")
    If chkSelected.Checked Then
    strTitle = CType(dgItem.FindControl("lblTitle"), Label).Text
    strSummary = CType(dgItem.FindControl("lblSumamry"), Label).Text
    strPostDate = CType(dgItem.FindControl("lblPostDate"), Label).Text
    lblSelections.Text += "Title: <b>" & strTitle & "</b> | "
    lblSelections.Text += "Summary: <b>" & strSummary & "</b> | "
    lblSelections.Text += "Date posted:: <b>" & strPostDate & "</b><br>"
    End If
    End Sub

    End Class

    End Namespace

    My aspx page is:

    <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="DotNetTony.storylist" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
    <title>View news stories</title>
    <form id="Form1" method="post" runat="server">
    <asp:Button ID="btnShow" Text="Delete Checked Rows" OnClick="ShowSelections" Runat="server" />
    <h1>News stories</h1>
    <aspataGrid ID="GridView1" runat="server"
    <asp:TemplateColumn HeaderText="Title">
    <asp:Label ID="lblTitle"
    Text='<%# DataBinder.Eval(Container.DataItem,"Title") %>'
    runat="server" />
    <asp:BoundColumn HeaderText="Summary" DataField="Summary" />
    <asp:BoundColumn HeaderText="Date Posted" DataField="PostDate" />
    <asp:BoundColumn HeaderText="ID" DataField="ID" Visible="False" />
    <asp:TemplateColumn HeaderText="ID" Visible="False">
    <asp:Label ID="lblID"
    Text='<%# DataBinder.Eval(Container.DataItem,"ID") %>'
    Runat="server" />
    <asp:TemplateColumn HeaderText="Delete" ItemStyle-HorizontalAlign="Center">
    <asp:CheckBox ID="chkSelection" Runat="server" />
    <AlternatingItemStyle BackColor="#DCDCDC" />
    <ItemStyle ForeColor="Black" BackColor="#EEEEEE" />
    <headerStyle Font-Bold="True" ForeColor="White" BackColor="#000084" />
    <asp:Label ID="lblSelections"
    Font-Size="10px" />


  • #2
    What is the whole error message you're getting? Also, have you searched Google? There seem to be a lot of posts in other forums on this problem. Perhaps one of them might provide a clue.
    Music Around The World - Collecting tips, trade and want lists, album reviews, & more


    • #3
      hi, sorry, forgot to actually include the error. It is...
       Compilation Error
      Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
      Compiler Error Message: BC30260: 'btnShow' is already declared as 'Protected Dim WithEvents btnShow As System.Web.UI.WebControls.Button' in this class.
      Source Error:
      Line 8:      Public Class storylist : Inherits System.Web.UI.Page
      Line 9:  
      Line 10:         Dim btnShow As Button
      Line 11:         Dim lblSelections As Label
      Line 12:
      I have googled, and the error is apparently because variables are declared twice, but in my limited knowledge, I cant see how in my code, hence I think it's me getting the logic wrong.


      • #4
        it is telling you that when you dragged a button onto the form and named it btnShow that it is declared already. then you go on and declare it again Look at all the code in the code behind and you should see where that button is declared like it is in the error message