'System.Web.UI.WebControls.SortDirection' is a 'type' but is use

G

Guest

I'm trying to use this malformed code from:
http://forums.asp.net/thread/1384075.aspx

In this method, I get the 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: CS0118: 'System.Web.UI.WebControls.SortDirection' is
a 'type' but is used like a 'variable'

Source Error:



Line 32: string newSortDirection = String.Empty;
Line 33:
Line 34: switch (SortDirection)
Line 35: {
Line 36: case SortDirection.Ascending


private string ConvertSortDirectionToSql(SortDirection sortDireciton)
{
string newSortDirection = String.Empty;

switch (SortDirection)
{
case SortDirection.Ascending:
newSortDirection = "ASC";
break;

case SortDirection.Descending:
newSortDirection = "DESC";
break;
}

return newSortDirection;
}
 
B

Bruce Wood

dba123 said:
I'm trying to use this malformed code from:
http://forums.asp.net/thread/1384075.aspx

In this method, I get the 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: CS0118: 'System.Web.UI.WebControls.SortDirection' is
a 'type' but is used like a 'variable'

Source Error:



Line 32: string newSortDirection = String.Empty;
Line 33:
Line 34: switch (SortDirection)
Line 35: {
Line 36: case SortDirection.Ascending


private string ConvertSortDirectionToSql(SortDirection sortDireciton)
{
string newSortDirection = String.Empty;

switch (SortDirection)
{
case SortDirection.Ascending:
newSortDirection = "ASC";
break;

case SortDirection.Descending:
newSortDirection = "DESC";
break;
}

return newSortDirection;
}

Well, apart from the fact that "sortDirection" is spelled wrong on the
following line:

private string ConvertSortDirectionToSql(SortDirection sortDireciton)
{
string newSortDirection = String.Empty;

switch (SortDirection)
{

the most likely cause is that C# is case-sensitive, so

switch (SortDirection)

is referring to the SortDirection type, whereas

switch (sortDirection)

would refer to the parameter, which is what you want.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top