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.
|
| Author: muralidhar 25 Jul 2008 | Member Level: Gold | Rating: 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.
|