urgent-codebehind not working

Discussion in 'ASP .Net' started by samir dsf, Jul 8, 2005.

  1. samir dsf

    samir dsf Guest

    hi
    i thinks its a very strange problem.I had been running my file
    ServerList2.aspx and i see the output(when i do f5). i am using this
    file serverList2.aspx on hte left side of a main page (using frames and
    all).when i run it its running fine.but when i just now check in the
    vs.net design mode inside the other aspx file(serverMain), where i
    inserted it on the left then i see this error:
    'dgversion_itemDataBound' is not a member of serverlist2.aspx

    why is this so?it means its not going to the codebehind at all! thats
    why i see no color change;can someone pls respond.what do i need to do.
    here is my ServerList2.aspx
    <%@ Import Namespace="System.Configuration" %>
    <%@ Import Namespace="System.Data.OleDb" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Page Language="vb" Debug="true" %>
    <HTML>
    <HEAD>
    <title>Database Connection Test</title>
    <script runat="server">
    sub Page_Load(sender as Object, e as EventArgs)


    'Create a connection string
    Dim connString as string
    Dim objConnection as OleDbConnection
    Dim strSQL, strSQL2 as string
    Dim objCommand, objCommand2 as OleDbCommand
    Dim objDataReader as OleDbDataReader


    'connstring = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
    SOURCE=C:\Inetpub\wwwroot\ServersNet\Servers.mdb;"

    'Open a connection
    connstring=ConfigurationSettings.AppSettings("ConnectionString")
    objConnection = New OleDbConnection(connstring)
    objConnection.Open()

    'Specify the SQL string
    'strSQL = "Select IDkey, ServerName from Backup where IDKey is not
    Null"
    'strSQL2 = "select Name, Dept, ApproveUser from ServerMain"
    strsql="SELECT Backup.IDKey, Backup.Servername, ServerMain.ApproveUser
    FROM backup INNER JOIN ServerMain ON Backup.IDKey = ServerMain.IDKey"
    'Create a command object

    objCommand = New OleDbCommand(strSQL, objConnection)
    'objCommand2 = New OleDbCommand(strSQL2, objConnection)
    'Get a datareader
    objDataReader =
    objCommand.ExecuteReader(CommandBehavior.CloseConnection)

    'Do the DataBinding w
    dgVersion.DataSource = objDataReader
    dgVersion.DataBind()

    'Close the datareader/db connection
    objDataReader.Close()

    end sub
    </script>
    </HEAD>
    <body>
    <asp:datagrid id="dgVersion" runat="server"
    AutoGenerateColumns="False" ShowFooter="True"
    OnItemDataBound="dgVersion_ItemDataBound">
    <Columns>
    <asp:TemplateColumn HeaderText="Server List"
    HeaderStyle-Font-Bold="True">
    <ItemTemplate>
    <asp:HyperLink id="AttachmentLink"
    Target="main" runat="server" NavigateUrl='<%# "ServerMain2.aspx?ID=" &
    Server.UrlEncode(Container.DataItem("IDKey")).Tostring()%>'>

    <%#DataBinder.Eval(Container.DataItem,"ServerName")%>
    </asp:HyperLink>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid><br>
    <br>
    </body>
    </HTML>
    here is my serverList2.aspx.vb
    pls suggest me as i have spent a day trying to color code m y datagrid
    output and it just doenst work because it never goes in codebehind.pls
    suggest me how to resolve this error


    Public Class ServerList2
    Inherits System.Web.UI.Page
    Protected WithEvents dgVersion As System.Web.UI.WebControls.DataGrid

    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub
    InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Init
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    InitializeComponent()
    End Sub

    #End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here


    End Sub

    Sub dgVersion_ItemDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    dgVersion.ItemDataBound
    'Dim itemType As ListItemType = e.Item.ItemType
    'If (e.Item.ItemType = ListItemType.Item Or _
    ' e.Item.ItemType = ListItemType.AlternatingItem Or
    e.Item.ItemType = ListItemType.EditItem) Then

    'If e.Item.Cells(1).Text = "APPLICATION" Then
    'If CType(e.Item.FindControl("AttachmentLink"), HyperLink).Text
    = "APPLICATION" Then
    'If e.Item.Cells(0).Text <> "" Then
    'e.Item.BackColor = Color.Red
    'Else
    ' e.Item.ForeColor = Color.Red
    'End If

    'End If
    Dim HPL As HyperLink = e.Item.FindControl("AttachementLink")
    If HPL.Text = "APPLICATION" Then
    e.Item.BackColor = Color.Red
    Else
    e.Item.BackColor = Color.Green
    End If

    End Sub

    Private Sub dgVersion_ItemCreated(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    dgVersion.ItemCreated

    End Sub
    End Class



    *** Sent via Developersdex http://www.developersdex.com ***
     
    samir dsf, Jul 8, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Dinnis

    Codebehind Events not working

    Mike Dinnis, Nov 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    479
    Mike Dinnis
    Nov 19, 2003
  2. =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=

    codebehind (c#) not working same as a .vb file

    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=, Nov 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    570
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Nov 29, 2004
  3. PeterKellner
    Replies:
    3
    Views:
    381
    clintonG
    Jun 8, 2006
  4. mike11d11
    Replies:
    0
    Views:
    371
    mike11d11
    Jul 30, 2010
  5. Prince Mathew

    URGENT-DataBinding expression in the codebehind

    Prince Mathew, Jan 26, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    158
    Prince Mathew
    Jan 26, 2005
Loading...

Share This Page