Click here to Skip to main content
12,949,816 members (74,972 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a grid view. I also have a 'Add Row to GridView' button. Now suppose, I have selected data present in the drop down list in the first row and when I click on the 'Add Row to GridView', another row gets added to the grid but the data selected in the first row disappears.

Please help.
Posted 27-Nov-12 3:31am
Mathlab 27-Nov-12 9:47am
You need to add the code to the question, use the improve question link to change your question and paste your code.
Lakhan Aanjana 27-Nov-12 10:04am
Put your code here then it will very help full for us
gilvani 27-Nov-12 10:58am
Did you mean that the selected index of dropdown not persisted?
samrat399 27-Nov-12 12:14pm
@Gilvani - yes the selected index didn't persist
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You have to write SetPreviousData method to solve this issue, because on button click autopost back will happen so , the data which you selected before will go off.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I have used two grid views here, say A and B.
I am showing the user grid view A and not grid view B.
What I am doing is whenever I add a new row, I am putting the contents of grid view A to grid view B and when the row gets added, the contents of grid view B are shown in A.

This might not be the best method of doing things but it works. Also, we are using EDMX to get data from database

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,489
CHill60 3,380
Maciej Los 2,913
Jochen Arndt 1,935
ppolymorphe 1,820

Advertise | Privacy | Mobile
Web02 | 2.8.170524.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100