Reputation: 460
I have a list in which there are more than one items. Now I want to get first element's value of tRecordCount
. I am trying, but getting an error System.FormatException: Input string was not in a correct format.
Can anyone tell me what is wrong in this code?
((HiddenField)GridViewPagingControl.FindControl("TotalRows")).Value = Convert.ToString(List.First(item => item.tRecordCount == Convert.ToInt32("tRecordCount")));
I have tried FirstOrDefault
and Single
too, but none is working. The return type of tRecordCount is int.
Thanks in Advance
Upvotes: 0
Views: 295
Reputation: 3611
May be what you want is this.
((HiddenField)GridViewPagingControl.FindControl("TotalRows")).Value = Convert.ToString(List.First().tRecordCount);
Upvotes: 1
Reputation: 13351
you have problem at statement
Convert.ToInt32("tRecordCount")
correct syntax in
Convert.ToInt32("/*valid integer value*/")
if tRecordCount is variable then this statement should be
Convert.ToInt32(tRecordCount)
Upvotes: 1
Reputation: 821
What's wrong is:
Convert.ToInt32("tRecordCount")
You cannot convert string to int
Upvotes: 0