like this:
| id | name | num | name2 |
| 1 | aaa | 4 | ddd |
| 2 | bbb | 6 | null |
| 3 | ccc | 1 | aaa |
| 4 | ddd | 5 | |
| 5 | eee | 2 | |
| 6 | 3 |
i want to compare id and num columns so that respective value must be display in name2 column
| id | name | num | name2 |
| 1 | aaa | 4 | ddd |
| 2 | bbb | 6 | null |
| 3 | ccc | 1 | aaa |
| 4 | ddd | 5 | |
| 5 | eee | 2 | |
| 6 | 3 |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Munesh SharmaRank #174 · 13.9K reputationPosted Apr 11, 2014, 3:54 AM EDT
samantaRank #3,157 · 454 reputationPosted Apr 11, 2014, 3:55 AM EDT
Munesh SharmaRank #174 · 13.9K reputationPosted Apr 11, 2014, 4:01 AM EDT
samantaRank #3,157 · 454 reputationPosted Apr 11, 2014, 4:02 AM EDT
Munesh SharmaRank #174 · 13.9K reputationPosted Apr 11, 2014, 4:10 AM EDT
but you have to do some changes here see this.
samantaRank #3,157 · 454 reputationPosted Apr 11, 2014, 4:13 AM EDT
samantaRank #3,157 · 454 reputationPosted Apr 11, 2014, 4:16 AM EDT
VulpesRank #55 · 29.2K reputationPosted Apr 11, 2014, 5:24 AM EDT
samantaRank #3,157 · 454 reputationPosted Apr 11, 2014, 5:28 AM EDT
Specified cast is not valid.
VulpesRank #55 · 29.2K reputationPosted Apr 11, 2014, 5:52 AM EDT
So I'd try replacing:
int num = (int)row.Cells["num"].Value;
with:
int num = Convert.ToInt32(row.Cells["num"].Value.ToString());
samantaRank #3,157 · 454 reputationPosted Apr 11, 2014, 6:02 AM EDT
Object reference not set to an instance of an object.
VulpesRank #55 · 29.2K reputationPosted Apr 11, 2014, 6:11 AM EDT
Also is it safe to assume that all rows will have a value in the id column and that the id's will be consecutive starting from 1 ?
samantaRank #3,157 · 454 reputationPosted Apr 11, 2014, 6:16 AM EDT
VulpesRank #55 · 29.2K reputationPosted Apr 11, 2014, 6:27 AM EDT