riskyricky1972
asked on
asp c#, IE 6.0
I have the following usercontrol. everything works fine except this one
public int producthowmany
{
get {txtproducthowmany.Text; }
set { txtproducthowmany.Text = value; }
}
I tried to call that and it is always saying that string cannot convert to integer. so I put
Int32.Parse() and it still does not work. Any ideas how to fixed it?
public string productname
{
get { return txtproductname.Text; }
set { txtproductname.Text = value; }
}
public string productdescription
{
get { return txtproductdescription.Text ; }
set { txtproductdescription.Text = value; }
}
public int producthowmany
{
get { return Int32.Parse(txtproducthowm any.Text); }
set { txtproducthowmany.Text = Int32.Parse(value); }
}
public int productcondition
{
get { return ddlproductcondition.Select edItem.Tex t; }
set { ddlproductcondition.Select edItem.Tex t = value; }
}
public float productpriceperunit
{
get { return txtproducthowmuch.Text; }
set { txtproducthowmuch.Text = value; }
}
public int producthowmany
{
get {txtproducthowmany.Text; }
set { txtproducthowmany.Text = value; }
}
I tried to call that and it is always saying that string cannot convert to integer. so I put
Int32.Parse() and it still does not work. Any ideas how to fixed it?
public string productname
{
get { return txtproductname.Text; }
set { txtproductname.Text = value; }
}
public string productdescription
{
get { return txtproductdescription.Text
set { txtproductdescription.Text
}
public int producthowmany
{
get { return Int32.Parse(txtproducthowm
set { txtproducthowmany.Text = Int32.Parse(value); }
}
public int productcondition
{
get { return ddlproductcondition.Select
set { ddlproductcondition.Select
}
public float productpriceperunit
{
get { return txtproducthowmuch.Text; }
set { txtproducthowmuch.Text = value; }
}
or try this also
public int producthowmany
{
get {
int i = 0;
i = int.TryParse(txtproducthow many.Text, out i); //check the syntex
return i;
}
set { txtproducthowmany.Text = Int32.Parse(value); }
}
public int producthowmany
{
get {
int i = 0;
i = int.TryParse(txtproducthow
return i;
}
set { txtproducthowmany.Text = Int32.Parse(value); }
}
ASKER
error point to set { txtproducthowmany.Text = Int32.Parse(value); }
to say that it can not convert from string to int.
to say that it can not convert from string to int.
textProductthowmany.Text is a string value so cannot assign a int value.
try like this
textProductthowmany.Text = value.ToString()
try like this
textProductthowmany.Text = value.ToString()
ASKER
and now I have dropdown.
and failed me again.
if (ddlproductcondition.Selec tedItem.Se lected.Len gth > 0 )
and failed me again.
if (ddlproductcondition.Selec
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you can check the value before parsing
public int producthowmany
{
get {
int i = 0;
if (txtproducthowmany.Text.Le
i = Int32.Parse(txtproducthowm
return i;
}
set { txtproducthowmany.Text = Int32.Parse(value); }
}