PLZ HELP ME

K

k_kris4u

I am geeting following errors.while running my project.plz respond asap its urgent!

thak u

Operator '==' cannot be applied to operands of type 'int' and 'object'
Cannot implicitly convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.DataGrid'
Cannot implicitly convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.DataGrid'







private void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{


if (e.CommandName == "showorders")
{



if (e.Item.ItemIndex == e.CommandArgument & (e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem))
{

string customerid;
customerid = ((Label)(e.Item.FindControl("Label2"))).Text;
DataGrid childgrid;
DataSet ds = GetOrdersDataSet(customerid);
childgrid = e.Item.FindControl("DataGrid1");
childgrid.DataSource = ds;
childgrid.DataBind();
childgrid.Visible = true;
((LinkButton)(e.Item.FindControl("LinkButton1"))).Text = "Hide Orders";
((LinkButton)(e.Item.FindControl("LinkButton1"))).CommandName = "hideorders";

}

else
if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem)
{
DataGrid childgrid;
childgrid = e.Item.FindControl("DataGrid1");
childgrid.DataSource = null;
childgrid.Visible = false;
((LinkButton)(e.Item.FindControl("LinkButton1"))).Text = "Show Orders";
((LinkButton)(e.Item.FindControl("LinkButton1"))).CommandName = "showorders";
}
}
}
 
D

Daniel

First use .Equals() to check for equality. == checks that the references
match whereas .equals checks the values match.

The error message is telling you what's wrong, your checking an int against
an object so cast the object (assuming it can be cast) to an int.

so for example rather than:

if(x.Equals(y)) //where y is the object

do

if(x.Equals((int)y)) ///where y is the object
 
C

chanmm

Your error message should indicate which line is the error so just look at
that line first.

chanmm
 
G

Greg Young

see below ...
I am geeting following errors.while running my project.plz respond asap its
urgent!

thak u

Operator '==' cannot be applied to operands of type 'int' and 'object'
Cannot implicitly convert type 'System.Web.UI.Control' to
'System.Web.UI.WebControls.DataGrid'
Cannot implicitly convert type 'System.Web.UI.Control' to
'System.Web.UI.WebControls.DataGrid'







private void DataList1_ItemCommand(object source, DataListCommandEventArgs
e)
{


if (e.CommandName == "showorders")
{

I believe your first issue is happenning here e.Item.ItemIndex ==
e.CommandArgument .. make commandargument an integer first (i.e. use
int.parse etc to verify it is of the right type).

if (e.Item.ItemIndex == e.CommandArgument & (e.Item.ItemType ==
ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem))
{

string customerid;
customerid = ((Label)(e.Item.FindControl("Label2"))).Text;
DataGrid childgrid;
DataSet ds = GetOrdersDataSet(customerid);
childgrid = e.Item.FindControl("DataGrid1");

Change to
childgrid = (DataGrid) e.Item.FindControl("DataGrid1");

childgrid.DataSource = ds;
childgrid.DataBind();
childgrid.Visible = true;
((LinkButton)(e.Item.FindControl("LinkButton1"))).Text = "Hide Orders";
((LinkButton)(e.Item.FindControl("LinkButton1"))).CommandName =
"hideorders";

}

else
if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
ListItemType.AlternatingItem)
{
DataGrid childgrid;
childgrid = e.Item.FindControl("DataGrid1");

Change to
childgrid = (DataGrid) e.Item.FindControl("DataGrid1");
 

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