Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Following are my code and it shows me error
index was out of range. must be non-negative and less than the size of the collection.


My Code
C#
txt_Name.Text = GridView1.SelectedRows[0].Cells[0].Value.ToString();
            txt_Email.Text = GridView1.SelectedRows[0].Cells[1].Value.ToString();
            txt_Mobile.Text = GridView1.SelectedRows[0].Cells[2].Value.ToString();
            txt_Address.Text = GridView1.SelectedRows[0].Cells[3].Value.ToString();
            txt_Company.Text = GridView1.SelectedRows[0].Cells[4].Value.ToString();
Posted
Updated 12-Sep-15 5:12am
v3
Comments
Richard MacCutchan 12-Sep-15 8:48am    
One of your cell references is invalid. Check your data to see which one.
Rohitk2409 12-Sep-15 8:51am    
here is my database

CREATE TABLE [dbo].[Dealer] (
[Email] VARCHAR (50) NOT NULL,
[Name] VARCHAR (50) NULL,
[Address] VARCHAR (50) NULL,
[Mobile] VARCHAR (50) NULL,
[Company] VARCHAR (50) NULL,
CONSTRAINT [PK_Dealer] PRIMARY KEY ([Email])
);

Rohitk2409 12-Sep-15 9:33am    
done, thank you :)

1 solution

Answered only to remove from unanswered list: solved by OP
 
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