Click here to Skip to main content
15,914,409 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionunknown error in c# web application Pin
Member 24081286-Feb-07 23:47
Member 24081286-Feb-07 23:47 
AnswerRe: unknown error in c# web application Pin
gauthee6-Feb-07 23:53
gauthee6-Feb-07 23:53 
AnswerRe: unknown error in c# web application Pin
Sylvester george6-Feb-07 23:57
Sylvester george6-Feb-07 23:57 
QuestionHow to update the xml file using datagrid in asp.net Pin
mohit Tyagi6-Feb-07 23:47
mohit Tyagi6-Feb-07 23:47 
AnswerRe: How to update the xml file using datagrid in asp.net Pin
blue_arc7-Feb-07 0:31
blue_arc7-Feb-07 0:31 
QuestionRead data from gridview Pin
mail5723526-Feb-07 23:35
mail5723526-Feb-07 23:35 
AnswerRe: Read data from gridview Pin
dinus286-Feb-07 23:49
dinus286-Feb-07 23:49 
GeneralRe: Read data from gridview Pin
mail5723527-Feb-07 0:37
mail5723527-Feb-07 0:37 
Thanks for your reply.

It is more likely for the column order to be changed rather than the name of the data field because the latter is what the gridview control is bound on.

The problem is that if the order of the columns changed, and the types of data were different as they are in my grid, the code would break. Whilst each column is a string value, some of those strings are actually numbers and I use a Parse method to parse them. If these methods tried to parse a string which wasn't actually a number, an exception would be raised.

Also, I pass the values to a method. If I use indexing, I have to arrange my parameters according to what position I read them in as, like this:

obj = new MyObject
(
   (String)(gvItems.Rows[i].Cells[0]).Text,        // Product code
   (String)(gvItems.Rows[i].Cells[1]).Text,        // Description
   (String)(gvItems.Rows[i].Cells[6]).Text,        // Part Number
   Decimal.Parse((gvItems.Rows[i].Cells[2]).Text), // Sales Price
   Decimal.Parse((gvItems.Rows[i].Cells[3]).Text), // Quantity
   Decimal.Parse((gvItems.Rows[i].Cells[5]).Text), // VAT Rate
   Decimal.Parse((gvItems.Rows[i].Cells[4]).Text)  // Discount
);


It's far better to use the name if at all possible.
GeneralRe: Read data from gridview Pin
dinus287-Feb-07 0:50
dinus287-Feb-07 0:50 
GeneralRe: Read data from gridview Pin
mail5723527-Feb-07 1:37
mail5723527-Feb-07 1:37 
AnswerRe: Read data from gridview Pin
gauthee6-Feb-07 23:50
gauthee6-Feb-07 23:50 
GeneralRe: Read data from gridview Pin
dinus286-Feb-07 23:54
dinus286-Feb-07 23:54 
GeneralRe: Read data from gridview Pin
gauthee7-Feb-07 0:01
gauthee7-Feb-07 0:01 
GeneralRe: Read data from gridview Pin
gauthee7-Feb-07 0:03
gauthee7-Feb-07 0:03 
GeneralRe: Read data from gridview Pin
mail5723527-Feb-07 0:39
mail5723527-Feb-07 0:39 
AnswerRe: Read data from gridview Pin
varshavmane6-Feb-07 23:57
varshavmane6-Feb-07 23:57 
AnswerRe: Read data from gridview Pin
Murthy Puvvada7-Feb-07 2:11
Murthy Puvvada7-Feb-07 2:11 
Questiondatagrid in a seperate cs file Pin
gauthee6-Feb-07 23:33
gauthee6-Feb-07 23:33 
AnswerRe: datagrid in a seperate cs file Pin
Paddy Boyd6-Feb-07 23:36
Paddy Boyd6-Feb-07 23:36 
GeneralRe: datagrid in a seperate cs file Pin
gauthee6-Feb-07 23:57
gauthee6-Feb-07 23:57 
GeneralRe: datagrid in a seperate cs file Pin
blue_arc7-Feb-07 0:34
blue_arc7-Feb-07 0:34 
GeneralRe: datagrid in a seperate cs file Pin
gauthee7-Feb-07 0:43
gauthee7-Feb-07 0:43 
QuestionOnline Radio Pin
M A A Mehedi Hasan6-Feb-07 23:29
M A A Mehedi Hasan6-Feb-07 23:29 
QuestionOrchestration Pin
indian1436-Feb-07 23:05
indian1436-Feb-07 23:05 
AnswerRe: Orchestration Pin
badgrs6-Feb-07 23:24
badgrs6-Feb-07 23:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.