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: 59 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:













custom profile provider problem

validation of viewstate mac failed

script timing out

how to turn off authentication on some pages?

security headjob

one way of getting around multi-hop credentials when calling a web service

login control

granting asp.net write access to file

help setting up membership provider

allow users when they sign up to choose thier role- problem

encryption error message

stppong the sharing of usernames/logins

single users profile and all users profiles list - how ?

windows authentication box appears

aspentdb connection error

can a user be assigned with more than one role ?

login page not rendering correctly

capturing message from oracle using c#

showing data that is related to a particular login user

personal web site starter kit publishing

how can i access remember me option in login control

extending membership properties

how to identify the authenticated request user

remoting securityexception problem

asp.net web application administration

microsoft security building block under win2k

protection v performance

so what do you think is wrong with this?

forms authentication failed - the ticket supplied has expired.

ssl page

defining roles for specific pages

.net vs intrusion detection

windows authentication asks for login/pwd!

encryption of client forms

loginview question

login page

default button + loginview + login problem

godaddy shared hosting and applications

searching ad and returning attributes

need example for custom membership providers

several important questions..

can you change password.format from hash to encrypted on existing membership database?

connecting to a database

publishing password protected site

asp.net sql server registration tool (aspnet_regsql.exe)

basic ssl cert question

idiot's guide to custom membership

application pool and registry permissions

membership - how can i authenticate against two providers?

set new domain password in asp.net 2?

   
  Privacy | Contact Us
All Times Are GMT