ASP.NET

That particular method is declared to return void (thus nothing) and inside the method it's returning something, hence the compiler is giving you this warning... (I think, hard to say when I can't see the source-code)
 
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;


public partial class Basket : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack && Context.User.Identity.IsAuthenticated)
{
GridView1.DataSource = Profile.Basket;
GridView1.DataBind();
}
}

protected void GridView1_OnRowCreated(object sender, GridViewRowEventArgs e)
{
string connectionString = "ConnectionStrings:ConnectionString";
System.Data.SqlClient.SqlConnection sqlconnection = new System.Data.SqlClient.SqlConnection(connectionString);

System.Data.SqlClient.SqlDataAdapter ad = new System.Data.SqlClient.SqlDataAdapter("SELECT * FROM [posters]", sqlconnection);
DataSet ds = new DataSet();
ad.Fill(ds);
return ds;

DataRow dr = ds.Tables[0].Rows[0];

Label blah = (Label)GridView1.FooterRow.FindControl("Label7");

blah.Text = dr["Units"].ToString();


}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (Context.User.Identity.IsAuthenticated)
{
TextBox tb =
(TextBox)GridView1.Rows[GridView1.SelectedIndex].Cells[1].Controls[1];
int newval = int.Parse(tb.Text);
Profile.Basket[GridView1.SelectedIndex].Units = newval;
Profile.Save();
GridView1.DataSource = Profile.Basket;
GridView1.DataBind();
}
}
protected void LinkButton1_Click1(object sender, EventArgs e)
{
if (Context.User.Identity.IsAuthenticated)
{
Profile.Basket.Clear();
GridView1.DataBind();
}
}


}
 
The problem is the following:

Your method 'GridView1_OnRowCreated' is declared as a method that has no return value (void), yet inside the method implementation you are trying to return a Dataset as the method return value, which is inconsistent with the method definition.

JS said:
void GridView1_OnRowCreated(object sender, GridViewRowEventArgs e)
{
string connectionString = "ConnectionStrings:ConnectionString";
System.Data.SqlClient.SqlConnection sqlconnection = new System.Data.SqlClient.SqlConnection(connectionStri ng);

System.Data.SqlClient.SqlDataAdapter ad = new System.Data.SqlClient.SqlDataAdapter("SELECT * FROM [posters]", sqlconnection);
DataSet ds = new DataSet();
ad.Fill(ds);
return ds;

DataRow dr = ds.Tables[0].Rows[0];

Label blah = (Label)GridView1.FooterRow.FindControl("Label7");

blah.Text = dr["Units"].ToString();


}

If you want the method to return a dataset, then you must change the 'void' before the method name into 'DataSet'.
 
first try commenting out the line: return ds; (by putting // in front of it) now the method is not supposed to return anything, and doesn't.
 
ive done that before abd it returns the error i had right from the begginning


DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Units'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Units'.

Source Error:


Line 14: </FooterTemplate>
Line 15: <ItemTemplate>
Line 16: <asp:Label ID="Label7" runat="server" Text='<%# Eval("Units") %>'></asp:Label>
Line 17: </ItemTemplate>
Line 18: </asp:TemplateField>


Source File: c:\Documents and Settings\jak\Desktop\JacksPosterShop\Basket.ascx Line: 16
 
jackybaby said:
ive done that before abd it returns the error i had right from the begginning


DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Units'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Units'.

Source Error:


Line 14: </FooterTemplate>
Line 15: <ItemTemplate>
Line 16: <asp:Label ID="Label7" runat="server" Text='<%# Eval("Units") %>'></asp:Label>
Line 17: </ItemTemplate>
Line 18: </asp:TemplateField>


Source File: c:\Documents and Settings\jak\Desktop\JacksPosterShop\Basket.ascx Line: 16

that's a complete different error. I thought Stelly sorted that out for you?
 
Back
Top Bottom