473,322 Members | 1,526 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,322 software developers and data experts.

C#NET2008 Retrieve Data from DataGridView

126 100+
Hullo Good Guys,
I need your help. Please help me.
I am very surprise of this error message:
Index was out of range. Must be non-negative and less thatnt he size of the collection. Parameter name :Index

I am using C#NET2008 and try to retrieve data from the Clicked Row and it’s not working to my surprised. It has not happened before. This particular problems is because the SQL String retrieve 13 data columns from SQL SERVER Table to fill the DataGridView for display.


This coding : string strHomePage = (string) this.DGVSupplier.CurrentRow.Cells[11].Value;
Generated the error message:


This is the SQL String which retrieve data from SQL SERVER to fill DataGridView DataSource via DataSet
string strSql = "SELECT SupplierID, CompanyName, ContactName, "
+ "ContactTitle, Address, City, Region, PostalCode, "
+ " Country, Phone, Fax, HomePage "
+ "FROM TBLSuppliers "
+ "ORDER BY SupplierID";

Expand|Select|Wrap|Line Numbers
  1. private void DGVSupplier_Click(object sender, EventArgs e)
  2.  {              
  3.   int intSuppId = (int)  this.DGVSupplier.CurrentRow.Cells[0].Value;
  4.   string strCompName = (string)  this.DGVSupplier.CurrentRow.Cells[1].Value;
  5.   string strContName = (string) this.DGVSupplier.CurrentRow.Cells[2].Value;
  6.   string strContTitle = (string) this.DGVSupplier.CurrentRow.Cells[3].Value;
  7.   string strAddr = (string) this.DGVSupplier.CurrentRow.Cells[4].Value;
  8.   string strCity = (string) this.DGVSupplier.CurrentRow.Cells[5].Value;
  9.   string strRegion = (string) this.DGVSupplier.CurrentRow.Cells[6].Value;
  10.   string strPostCode = (string) this.DGVSupplier.CurrentRow.Cells[7].Value;
  11.   string strCountry = (string) this.DGVSupplier.CurrentRow.Cells[8].Value;
  12.   string strPhone = (string) this.DGVSupplier.CurrentRow.Cells[9].Value;
  13.   string strFax = (string) this.DGVSupplier.CurrentRow.Cells[10].Value;
  14.   string strHomePage = (string) this.DGVSupplier.CurrentRow.Cells[11].Value;    <---- Error here
  15.  }
  16.  

Please help me. Thank you very much
Attached Images
File Type: jpg DGVSupplier.jpg (96.1 KB, 77 views)
Nov 22 '10 #1
0 1346

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Miki | last post by:
Hi. I have a IIS server with php3 installed. I have SQL server database and data stored in unicode format (nvarchar fields). In header of my php I have the meta: <meta HTTP-EQUIV="content-type"...
4
by: Claudia Fong | last post by:
Hi, I have a form where I need to display the data of a department that stores in a access db. When I first load the form it will call a function name loaddata which will get the first...
1
by: funcSter | last post by:
I want to retrieve data from an Excel file like how I would with a database. I understand that I would have to use OLE DB. Somehow I think I cannot get the connection string right, as the bit of...
5
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say...
1
by: kmanjani | last post by:
hi, i have to retrieve data from 4 tables at a time...can anyone guide me in wrting a query for the same.. Ex:- i have four fields f1,f2,f3,f4 which i need to retrieve from four tables...
3
by: karthigaj | last post by:
Hi, Happy new Year... i need to retrieve the data from the web server which is developed using HTML and i need to process those data in c but i should not use any CGIs. Can anybody help me...
1
by: gudipati | last post by:
hi,i have one problem.actually we can retrieve data from access. what is my requirement is when i retrieve data from access i want to store in text areas. finely,we can store if they r textboxes...
2
by: singhanand2009 | last post by:
how could i retrieve data from database for a particular field. example- i have got a table having id as primary key, password, and other entity. how could i retrieve only one colum such as id.
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
0
by: lenniekuah | last post by:
Hi Friends, I need your help. Please help me. I am trying to retrieve data from Excel Spreadsheet to fill the DataGridView for display prior to updating SQL SERVER with individual DataGridView...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.