Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
string intno,intno2;

               //Get the intno
               intno = GridView1.SelectedRow.Cells[1].Text;
               intno2 = GridView1.SelectedRow.Cells[7].Text;


 //call the stored procedure
               SqlCommand SqlCmd = new SqlCommand("sp_GetActLoanid", sqlcon);
               SqlCmd.CommandType = System.Data.CommandType.StoredProcedure;



please explain the references cells[1] , cell[7]

re lang="sql"> intno = GridView1.SelectedRow.Cells[1].Text;
intno2 = GridView1.SelectedRow.Cells[7].Text;

Thanks
Posted
Comments
CHill60 5-Sep-14 15:33pm    
It's retrieving the text in the 2nd and 8th columns of the grid. What's the problem?
ZurdoDev 5-Sep-14 15:41pm    
That's a solution.
kbrandwijk 5-Sep-14 17:39pm    
I never understood how unbound grids, or not using the underlying datasource to read the data, got so popular so fast...
[no name] 5-Sep-14 19:03pm    
It became popular at about the same time that people started "learning" programming by copy/paste instead of studying and taking classes.
George Jonsson 6-Sep-14 3:42am    
I couldn't agree more.

1 solution

sir, the above code "Cells[1],Cells[8]" are used to get data from the datagridview. let me give you another simple example for this:-
datagridview1.SelectedRows["Col_Name"].Text;
datagridview1.SelectedRows[1].Text;

both of the above line does the same work and "Cells[1],Cells[8]" in the above context means that you are trying to access cells of current focused column of datagridview at position 2 and 8.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900