Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input string not in correct format

Status
Not open for further replies.

quinnipiac0807

Programmer
Oct 25, 2004
38
US
I'm trying to pass a variable from one page to another and I"m getting the input string in correct format error. I usually can work arround this error but this time I can't. Here's the code.

protected void grdAssets_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
AssCustID = e.Item.Cells[6].ToString();

if (e.Item.FindControl("btnDelAssign") != null)
((ImageButton) e.Item.FindControl("btnDelAssign")).Attributes.Add("onclick", "showModal('itd/itdDeleteAssignment.aspx?acID=" + AssCustID + "', 'Delete Assignment', '', 'status:no;scroll:no;', 250, 450, false)");
}

The code on the next page to recieve it is next.

private void btnOk_Click(object sender, System.EventArgs e)
{
DeleteAsset(Convert.ToInt32(AssCustID));
}

I get the error when I try to convert it to an int32. Any suggestions. Thanks again!!!
 
How are you setting AssCustID's value in the second page? Are you reading the QueryString?

Hope everyone is having a great day!

Thanks - Jennifer
 
you might receive this in the case where AssCustID in the first page is empty

instead of AssCustID = e.Item.Cells[6].ToString() use
Code:
try
{
    AssCustID = int.Parse(e.Item.Cells[6].ToString());
}
catch
{
    AssCustID = -1;
}

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top