Input string was not in a correct format. ...Error is coming...

Posted by See29ram under ASP.NET on 12/7/2011 | Points: 10 | Views : 2562 | Status : [Member] | Replies : 9
int rowno = Convert.ToInt32(hdnvalue.Value);
in that i got this error.... help me friends...




Responses

Posted by: Sksingh on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

You might have null or empty value for "hdnvalue" .

try below code
int rowno = 0;

if(!string.IsEmptyOrNull(hdnvalue.Value))
{
rowno = Convert.ToInt32(hdnvalue.Value);
}


Regards,
Sunil

See29ram, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: See29ram on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
yes...im getting hdnvalue="null"
i think my rowdatabounevent is not calling javascript function.i dont know why??,tell me if i made anything wrong....


protected void grdempissues_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblempid = (Label)e.Row.FindControl("lblempid");
lblempid.Attributes.Add("Onkeypress", "javascript:return Validate('" + e.Row.RowIndex + "')");
}
}

my javscript function is,

function Validate(rowno)
{
document.getElementById("hdnvalue")=rowno;
}



See29ram, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

first of all check by debuging your code whether your javascript function get fire or not.

and one more thing you have not set hiddenfield value properly.
it should be like below.

function Validate(rowno) 

{
document.getElementById("hdnvalue").value =rowno;
}


hope it will work now..

Regards,
Sunil

See29ram, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: See29ram on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down

hi sksingh,
now i kept what u have mentioned...like
function Validate(rowno)
{
document.getElementById("hdnvalue").value =rowno;
}
i dont know why my javascript fun is not firing...
is there anything wrong in my rowdatabounevent???


See29ram, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
hi,

I dont know why did u write keypress event on lblempid

Eventhough just put breakpoint at your javascript code and function and after key press on lable just check it out whether you JS fucntion get fire ?



Regards,
Sunil

See29ram, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: See29ram on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
Nope...my JS function is not firing......


See29ram, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
Debub from begining and try to find out where is flaw,
I guess your problem is here

protected void grdempissues_RowDataBound(object sender, GridViewRowEventArgs e) 

{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblempid = (Label)e.Row.FindControl("lblempid");
lblempid.Attributes.Add("Onkeypress", "javascript:return Validate('" + e.Row.RowIndex + "')");
}
}



check whether attribute getting adding or not ??

Regards,
Sunil

See29ram, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: See29ram on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
i need to find out current row of gridview using outside button(which is not placed inside the grid)...so im try to read each row using rowdatabound and Js fun....but my rowdatabound event is not calling js function... if u have other solutions let me know.....

See29ram, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: See29ram on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
yes...its read that attributes..i m getting value of .e.Row.RowIndex but it not calling JS function...

See29ram, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response