C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Rectify My error.


Posted Date: 25 Jul 2008      Total Responses: 1

Posted By: sreemani       Member Level: Gold     Points: 1


i got this type error.

c:\Asp(Prac)\GETVALUES(EXCELSHEET)\Default2.aspx.cs(56,12): error CS1519: Invalid token 'string' in class, struct, or interface member declaration


but, i wrote code like that,


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Default2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings.Get("Constring1"));
double myTotal = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetGridValues();
}

}
protected void GetGridValues()

{
con.Open();
string str = "SELECT TOP 10 PRODUCTID,PRODUCTNAME,QUANTITYPERUNIT,UNITPRICE From NWPRODUCTS ORDER BY UNITPRICE DESC";
SqlDataAdapter da = new SqlDataAdapter(str, con);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1 .DataSource = dt;
GridView1.DataBind();
con.Close();

}

void GVData_Bound(object sender, GridViewRowEventArgs e)
{
if ((e.Row.RowType == DataControlRowType.Footer ))
{

e.Row.Cells[3].Text = "SUM OF TOTAL=";
//if (e.Row.Cells[3].Text ="SUM OF TOTAL=")
//{
// e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Right;
//}
e.Row.Cells[4].Text = myTotal.ToString("c");
e.Row.Cells[3].Font.Size = FontUnit.Point(12);
e.Row.Cells[4].Font.Size = FontUnit.Point(12);

}
}

Public string DoTotals(double iPrice, string iInstock)
{
int lg;
lg = iInstock.IndexOf(" ");
iInstock = iInstock.Substring(0, lg);
string str = string.Format("{0:c}", (iPrice * (int.Parse)(iInstock)));
string DoTotal = string.Format("{0:c}", (iPrice * int.Parse(iInstock)));
myTotal = (myTotal + double.Parse(DoTotal));
myTotal = (myTotal + (double.Parse)(str));
}
}


please rectify my error.Otherwise give me suggestions.





Responses

Author: muralidhar    25 Jul 2008Member Level: GoldRating:     Points: 6
Hai,

problem is with letter "P" in declaration of the last method.
it should be "p" and i have changed that.

one more thing is you have taken string as return type for "DoTotals" mehtod. but that method not returning any thing. thats also causes an error. i have changed that also.

just replace your existing code with the following.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Default2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings.Get("Constring1"));
double myTotal = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetGridValues();
}

}

protected void GetGridValues()
{
con.Open();
string str = "SELECT TOP 10 PRODUCTID,PRODUCTNAME,QUANTITYPERUNIT,UNITPRICE From NWPRODUCTS ORDER BY UNITPRICE DESC";
SqlDataAdapter da = new SqlDataAdapter(str, con);
DataTable dt = new DataTable();
da.Fill(dt);
//GridView1.DataSource = dt;
//GridView1.DataBind();
con.Close();
}

void GVData_Bound(object sender, GridViewRowEventArgs e)
{
if ((e.Row.RowType == DataControlRowType.Footer))
{
e.Row.Cells[3].Text = "SUM OF TOTAL=";
//if (e.Row.Cells[3].Text ="SUM OF TOTAL=")
//{
// e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Right;
//}
e.Row.Cells[4].Text = myTotal.ToString("c");
e.Row.Cells[3].Font.Size = FontUnit.Point(12);
e.Row.Cells[4].Font.Size = FontUnit.Point(12);
}
}

public string DoTotals(double iPrice, string iInstock)
{
int lg;
lg = iInstock.IndexOf(" ");
iInstock = iInstock.Substring(0, lg);
string str = string.Format("{0:c}", (iPrice * (int.Parse)(iInstock)));
string DoTotal = string.Format("{0:c}", (iPrice * int.Parse(iInstock)));
myTotal = (myTotal + double.Parse(DoTotal));
myTotal = (myTotal + (double.Parse)(str));
return myTotal.ToString();
}
}

Regards,
Muralidhar.



Post Reply
You must Sign In to post a response.
Next : help me(unable to connect visual studio's local web server)
Previous : If i don't have access for database which is used in webservice, what can i do to get it
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design   Scripts

doors in nj

Contact Us    Privacy Policy    Terms Of Use