UpdatePanel and Gridview / DetailsView

M

mike

I have a page with a LoginView which contains a Gridview and a
DetailsView, each in its own UpdatePanel

The problem that I am experiencing is that when I select a record in
the Gridview (using a SelectButton), the selected record is shown in
the DetailsView, which is correct - however, when I choose "Update" on
the DetailsView I am presented with the EditItemTemplate which
contains the first record in the DetailsDataSource.

The code that changes the selected record in the DetailsView is in the
GridView1.SelectedIndexChanged event as:

protected void GridView1_SelectedIndexChanged(object sender, EventArgs
e)
{
GridView gv1 =
(GridView)LoginView1.FindControl("GridView1");
DetailDataSource.FilterExpression = "ID='" +
gv1.SelectedValue.ToString()+"'";
}

Clicking the "Select" button on the GridView while the DetailsView is
in either "ReadOnly" or "Edit" modes loads the DetailsView with the
correct record - but switching views causes the record to go back to
the default (1st) record.

I am wondering if the update panels may be causing the problem -
should everything be in a single update panel?
It's my first time playing with the control so I'm not sure about all
of the intricacies with it yet.


Any help would be greatly appreciated.

Mike
 
T

Teemu Keiski

Hi,

quickly thinking it indeed sounds as if they should be in a single
updatepanel when change in other flows immediately to the another control
(otherwise you'd need to trigger updates for the panels). This is just
guessing, but try putting them into single UpdatePanel first.
 
M

mike

Teemu,

Thanks for your help! I placed the controls inside a single
UpdatePanel and changed a couple of setting in the DataSources and I
have it working nicely. Thanks again!

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top