Problem in using GridView

I have one gridview and a detailview as i click select option , in gridview , a detailview is visible where i update my data and after updating it , i want that the updated data is visible in gridview as well , but i'm unable to show this updated data in grid view...
I'm attaching my code below...
Fdetails1.aspx
Fdetails1.aspx.cs
Sukesh ShuklaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lokesh B RDeveloperCommented:
Hi,

Change the code as below and try

 protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
        {
            GridView1.DataSource = GetData();
             GridView1.DataBind();
            GridView1.SelectRow(-1);
        }

Open in new window

0
Sukesh ShuklaAuthor Commented:
Hi Lokesh
Thanks for your reply, but still its not getting updated......
0
Lokesh B RDeveloperCommented:
Hi,

You need to remove the OnUpdated event on Gridview and add it to DetailsView.


        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="Flat" DataSourceID="SqlDataSource2" GridLines="Vertical" Height="50px" Width="125px"   OnItemUpdating="GridView1_RowUpdated" >
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Sukesh ShuklaAuthor Commented:
On doing the above step , the following error is shown:- I have attatched the snippet below.


This is the error shown..........
0
Lokesh B RDeveloperCommented:
Hi,
Do the changes as below.

1. Remove this event on GridView - OnRowUpdated="GridView1_RowUpdated".

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataKeyNames="Flat" >

2. Add the event on the DetailsView

<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="Flat" DataSourceID="SqlDataSource2" GridLines="Vertical" Height="50px" Width="125px"   OnItemUpdated="DetailsView1_ItemUpdated">


3. Add the code in .CS file


  void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
  {
    GridView1.DataSource = GetData();
             GridView1.DataBind();
            GridView1.SelectRow(-1);
  }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sukesh ShuklaAuthor Commented:
Thank You Lokesh........For your precious time..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.