Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 13th, 2004, 03:40 PM
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default This is driving me nuts!!! (datagrid in .ascx)

I have a VERY simple aspx page that has a usercontrol in it that just displays a list of names when you click a button. If I use this method for data retrieval/display it works:

try
      Dim connectionString As String
      connectionString = "Provider = Microsoft.Jet.OLEDB.4.0 ;User Id =;Password =;Data Source = " & dbName

      Dim myConnection As New OleDbConnection(connectionString)
      Dim myCommand As New OleDbCommand()
      Dim myInsertString As String

      myCommand.Connection = myConnection
      myConnection.Open()
      myInsertString = "select * from " & tName
      myCommand.CommandText = myInsertString

      datagrid1.datasource = myCommand.ExecuteReader()
      datagrid1.databind()

      myconnection.close()
    catch ex as exception
      response.write("Error : " & ex.message)
    end try

However, I need to use this code because this is the method used in other areas of the site:

try


     Dim cSearchText As String
        Dim cSearchText2 As String
        Dim Database As New ASGCommon.Database()
        Dim Dataset As New DataSet()


        Dim SQL2 As New System.Text.StringBuilder()

        cSearchText = "Adams"

        SQL2.Append("execute spGetDirectory @cSearch='" & cSearchText & "' ")

        Dataset = Database.GetDataSet("Employees", SQL2.ToString())

        Dim dvWebUsers2 As DataView = Dataset.Tables("Employees").DefaultView

        datagrid1 = New DataGrid()

        datagrid1.DataSource = dvWebUsers2
        datagrid1.DataBind()

    catch ex as exception
      response.write("Error : " & ex.message)
    end try

I know that the stored proc is working because I can retrieve a recordcount and it is accurate.

It has to be the binding to the grid. What am I missing???

I'm thinking of a reward here since I have been stuck on this way too long!!!
 
Old December 13th, 2004, 03:43 PM
Authorized User
 
Join Date: May 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What is the nature of the problem?

SS
 
Old December 13th, 2004, 03:48 PM
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I have a page (index.aspx) that has a placeholder in it that I want to use to bind different datagrids to depending on what action the user takes. Essentially to reuse the same page over and over.

I set the "include" up like this:

placeholder.controls.add(loadcontrol("usercontrol. ascx")

*Where usercontrol.ascx holds the creation and binding of a datagrid*

When I do something simple like set the text of a label, it works fine. However, when I try to create a datagrid and then bind it, nothing happens. No error or anything. And when I step through it, it does everything is is supposed to do.

Is there something I am missing with the data binding?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! CommandButton Caption Driving Me Nuts! phoenixblue C# 0 September 29th, 2006 03:19 AM
This is driving me nuts... Klesk C# 3 January 27th, 2006 06:51 PM
Driving me nuts! bhd8ball Classic ASP Professional 2 January 7th, 2005 12:55 AM
English Query Problem is Driving me Nuts... davidlars99 Classic ASP Professional 0 September 29th, 2004 01:29 PM
Type mismatch - Going Nuts ivanv ASP.NET 1.0 and 1.1 Basics 1 July 10th, 2003 03:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.