473,379 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Proper strinfg format

It is giving me error that input string is not in proper format.
What's wrong.
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (Convert.ToInt32(e.Row.Cells[2].Text) >=13)
{
e.Row.Cells[0].Text = "Hello" }

}

Jun 21 '07 #1
4 1131
The "input string" is the string you try to convert. Basically it means that
the value that is contained in e.Row.Cells[2].Text can't be converted to
Int32.
---
Patrice

<bb****@yahoo.coma écrit dans le message de news:
11**********************@i38g2000prf.googlegroups. com...
It is giving me error that input string is not in proper format.
What's wrong.
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (Convert.ToInt32(e.Row.Cells[2].Text) >=13)
{
e.Row.Cells[0].Text = "Hello" }

}

Jun 21 '07 #2
Have you examined the value of e.Rows.Cells[2].Text to make sure it holds a value that should convert to int? You can expect this error when attempting to

Convert.ToInt32("");

--
Jimmy V
..NET Development Team - CTS, Inc
jv*********@hotmail.com

www.askcts.com
<bb****@yahoo.comwrote in message news:11**********************@i38g2000prf.googlegr oups.com...
It is giving me error that input string is not in proper format.
What's wrong.
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (Convert.ToInt32(e.Row.Cells[2].Text) >=13)
{
e.Row.Cells[0].Text = "Hello" }

}
Jun 21 '07 #3
On Jun 21, 10:43 am, "Jimmy V" <jvanyne...@hotmail.comwrote:
Have you examined the value of e.Rows.Cells[2].Text to make sure it holds a value that should convert to int? You can expect this error when attempting to

Convert.ToInt32("");

--
Jimmy V
.NET Development Team - CTS, Inc
jvandyne...@hotmail.com

www.askcts.com

<bba...@yahoo.comwrote in messagenews:11**********************@i38g2000prf.g ooglegroups.com...
It is giving me error that input string is not in proper format.
What's wrong.
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (Convert.ToInt32(e.Row.Cells[2].Text) >=13)
{
e.Row.Cells[0].Text = "Hello" }
}- Hide quoted text -

- Show quoted text -
It's not holding the value. Please help me I don't know how to fix
it.
Jun 21 '07 #4
bb****@yahoo.com-

I'd try using TryParse first and then incorporate the if/then statement into
it.

// Example of e.Row.Cells[2].Text = "" (a blank string)
string cell2 = "";

// Example of e.Row.Cells[0].Text having it's value set.
string cell0 = "";
int result;
bool success = Int32.TryParse(cell2, out result);
if (success)
cell0 = (result >= 13) ? "Hello" : "";

This checks to see if it CAN parse before it checks your logic of result
>= 13. You could also place an else clause in there for when success ==
false. Replace cell2 and cell0 with your e.Row.Cells[0] and [2]; I just needed
a few strings to use to illustrate the point.

For more information on the Int32.TryParse method, check out : http://msdn2.microsoft.com/en-us/library/f02979c7.aspx

HTH.

-dl

--
David R. Longnecker
http://blog.tiredstudent.com
On Jun 21, 10:43 am, "Jimmy V" <jvanyne...@hotmail.comwrote:
>Have you examined the value of e.Rows.Cells[2].Text to make sure it
holds a value that should convert to int? You can expect this error
when attempting to

Convert.ToInt32("");

--
Jimmy V
.NET Development Team - CTS, Inc
jvandyne...@hotmail.com
www.askcts.com

<bba...@yahoo.comwrote in
messagenews:11**********************@i38g2000prf. googlegroups.com...
>>It is giving me error that input string is not in proper format.
What's wrong.

protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (Convert.ToInt32(e.Row.Cells[2].Text) >=13)
{
e.Row.Cells[0].Text = "Hello" }
}- Hide quoted text -
- Show quoted text -
It's not holding the value. Please help me I don't know how to fix
it.

Jun 21 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ksenia Marasanova | last post by:
Hi, I have a little problem with encoding. Was hoping maybe anyone can help me to solve it. There is some amount of data in a database (PG) that must be inserted into Excel sheet and emailed....
59
by: Haines Brown | last post by:
I've not had a clear definition in my mind of "citation," and so have avoided it. For example, if I suggest that the reputation of the New York Times has suffered, is that a citation? I suppose...
9
by: Microsoft News Server | last post by:
Hi, I am currently having a problem with random, intermittent lock ups in my ASP.net application on our production server (99% CPU usage by 3 threads, indefinately). I currently use IIS Debug...
18
by: Andrew Christiansen | last post by:
Hey all. The images I create in photoshop with semi-transparent pixels (for instance in Photoshop text with a dropshadow with a transparent canvas) I've been saving in PNG format and then using...
0
by: indian143 | last post by:
Hi all, Can I get any .net developpped library with proper UI, which gives the same functionality as DSO Framer control thats to display and edit office doc, xls etc files. Because the DSO Framer...
1
by: BurtonBach | last post by:
What is the proper format usage for the cdate command in a query? Does it change if used in a grouping line? Thanks,
2
by: CD | last post by:
I have a asp page pulling results from an Access DB. I have no control of the data input to the db. All the information is entered in Upper case. It contains fields like address, city, etc.. ...
2
by: mo/-/sin | last post by:
i made a table in sql server 2005 and there is column name dateofjoining... but whenever i insert a value in this column it shows some other value........ suppose i insert 2005-09-25 but it shows...
1
nurikoAnna
by: nurikoAnna | last post by:
how to properly separate sql codes........ I am using &_ as a separator...because it will not suits the visual basic code form...it will skip to the next line that's why I am having trouble in it...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.