CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > general_asp.net.getting_started Tags:
Item Type: Date Entered: 4/5/2005 3:43:42 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 56 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
"rorymccarthy"
NewsGroup User
A namespace does not directly contain members such as fields or methods - Datagrids4/5/2005 3:43:42 PM

0

Hello,

Im getting the error:

c:\inetpub\wwwroot\GP\WebForm1.aspx.cs(55): A namespace does not directly contain members such as fields or methods.

The code is shown below. It uses an object I have created to display data on a datagrid, with methods for sorting.

The line bringing up the error is highlighted in red, it is automatically generated code.

 

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using GP.Classes;

 

namespace GP

{

/// <summary>

/// Summary description for WebForm1.

/// </summary>

public class WebForm1 : System.Web.UI.Page

{

protected System.Web.UI.WebControls.DataGrid DataGrid1;

private void Page_Load(object sender, System.EventArgs e)

{

if (!(Page.IsPostBack))

{

FillGrid("DrugNo");

}

}

public void FillGrid(string SortCommand)

{

DrugInformation oDrugInformation = new DrugInformation("Provider=Microsoft.Jet.OLEDB.4.0;"

+ "Data Source=C:\\Inetpub\\wwwroot\\GP\\GeneralPractice.mdb;"

+ "Persist Security Info=False",

"C:\\Inetpub\\wwwroot\\GP\\drugInformation_log_file.txt");

DataSet dsDrugInformation = oDrugInformation.GetAllDrugInformation(SortCommand);

DataGrid1.DataSource = dsDrugInformation;

DataGrid1.DataBind();

dsDrugInformation.Dispose();

oDrugInformation = null;

}

public void OnSort(object sender, DataGridSortCommandEventArgs e)

{

FillGrid(e.SortExpression);

}

 

}

 

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

 

Appreciate any help,

 

Cheers

"DarrellNorton"
NewsGroup User
Re: A namespace does not directly contain members such as fields or methods - Datagrids4/5/2005 5:01:48 PM

1

Your second end curly brace after the OnSort method:

public void OnSort(object sender, DataGridSortCommandEventArgs e)

{

FillGrid(e.SortExpression);

}

}   ---- THIS ONE!!

Should go at the very end of all your code.  Basically you ended your class with that curly brace, and you were trying to define the OnInit method directly in the namespace instead of inside the Webform1 class.  Thus the error warning you got.



Darrell Norton, MVP
My Blog on CodeBetter
"rorymccarthy"
NewsGroup User
Re: A namespace does not directly contain members such as fields or methods - Datagrids4/5/2005 7:21:53 PM

0

Thanks alot. That worked a treat!

Rory

3 Items, 1 Pages 1 |< << Go >> >|


Free Download:













delete a project

visual studio 2005 beta problem

"web form" missing from add new item dialog window

cannot change any controls id values

dynamic documentation from documentation tags i source code

creating own keywords in visual studio

visual studio 2005 or 2003?

setting meta tags dynamically

generate local resource question

how do i know my sql 2005 ctp build is latest

what is the best place to place the connection string?

custom control array property (is read only!?!)

change source code issues

how to start debugging..!!

unable to start debugging on the web server

constant compilation during web development

macro event for when designer has finished loading?

newbie -- copying existing aspx and aspx.vb files into whidbey

"not a valid virtual path" error in vs 2005

no release mode in visual studio 2005

what good is the file system web server in vs.net 2005 if your database is on a remote box?

how to use precompiled deployment compilation model by default ?

use team settings file - on a per solution basis?

is there a run command to open up visual studio 2005?

is this normal behavior?

deployment projects in standard edition

how do i get the configuration manager to use a domain

wcf

error "some of the files required for web references are not installed"

problem: title attribute

adding reference to web project

simple question on database data editing..

web application not available in new project selection

surce formating problem

.net framework 2.0 - rtm?

access web user control from other project?????

can i maintain a .net v1.1 app w/ vs.net 2005?

charts, excel in vs 2005

publish website overwrites / erases existing ntfs directory permissions on server

timer object blocks form thread

what does the vs.net 2005 beta cost

debugging not loading screen unless i move mouse, or alt-tab to different window...

how to use vss?

i can not open asp.net project from office to work at home

reading registry keys on remote machines

vss get, compile, publish web site in whidbey?

problem installing visual studio 2005 on my windows xp sp2 pc

problem with vs 2005: quick find ctrl + f, quick replace ctrl + h, etc.

remote debugging cannot work

the difference between implementing an interface method implicitly and explicitly?

   
  Privacy | Contact Us
All Times Are GMT