Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Puffin Rock Characters Plush Toy Set
anil1961
Updated:
Saturday at 3:51 PM
Toyota Vitz scp10 For Sale
Lakmal Bandara
Updated:
Nov 4, 2026
Kandy
Welcome all my all new pet shop Bark.lk
dilumrane
Updated:
Nov 2, 2026
Windows RDP Only Rs.500 a month
Blogerwiki
Updated:
Nov 1, 2026
Ad icon
V2ray VPN for Tunneling
hu KANNA
Updated:
Oct 22, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
C# Programing FAQ - Post here
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Ranhiru" data-source="post: 4821281" data-attributes="member: 17748"><p>Machan the first one is a problem because the column has a NULL value in it. Does the "Amount" column contain a null value??? If the "Amount" column contains NULL values, then it should be handled separately.</p><p></p><p></p><p>And for the second problem i think Amount should work :S</p><p></p><p>If amount does not seem to work, simply use the column index <img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></p><p></p><p>So if the Amount column is the 3rd one, then the index is 2, because in C# its zero based indexes. </p><p></p><p></p><p>[code]int i = 0;</p><p> int Total = 0;</p><p></p><p></p><p> for (i = 0; i < costDataGridView1.Rows.Count; i++)</p><p></p><p> {</p><p> if (costDataGridView1.Rows[i].Cells[2].Value != null)</p><p> Total += Int32.Parse(costDataGridView1.Rows[i].Cells[2].Value.ToString());</p><p></p><p> }</p><p> this.textBox1.Text = Total.ToString();[/code] </p><p></p><p>So this is perfectly all right too <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /> Using the index instead of the name <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /> Notice that now i check whether the value is not null. If Int32.Parse giving you any errors, try the Convert Class. Use Convert.ToInt32(whatever)...</p><p>Hope this helps <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /></p></blockquote><p></p>
[QUOTE="Ranhiru, post: 4821281, member: 17748"] Machan the first one is a problem because the column has a NULL value in it. Does the "Amount" column contain a null value??? If the "Amount" column contains NULL values, then it should be handled separately. And for the second problem i think Amount should work :S If amount does not seem to work, simply use the column index :D So if the Amount column is the 3rd one, then the index is 2, because in C# its zero based indexes. [code]int i = 0; int Total = 0; for (i = 0; i < costDataGridView1.Rows.Count; i++) { if (costDataGridView1.Rows[i].Cells[2].Value != null) Total += Int32.Parse(costDataGridView1.Rows[i].Cells[2].Value.ToString()); } this.textBox1.Text = Total.ToString();[/code] So this is perfectly all right too :) Using the index instead of the name :) Notice that now i check whether the value is not null. If Int32.Parse giving you any errors, try the Convert Class. Use Convert.ToInt32(whatever)... Hope this helps :) [/QUOTE]
Insert quotes…
Verification
Hathara warak wissa keeyada? (Hathara wadi karanna 20)
Post reply
Top
Bottom