Select button GridView Datasource Select Object

Select button GridView Datasource Select Object

Old forum URL: forums.lhotka.net/forums/t/1758.aspx


georgeb posted on Tuesday, November 14, 2006

I am confused. I have a gridview (ASP.NET 2.0) and I display some rows of data having a Select button on each row. Also in the form I have an edit button to edit the selected row . I use a detailsview to edit the data. The first time works! It fires the Datasource select object and it fills correctly the detailsview. All the other times does not work. It brings the first selected row. Any suggestions on what I am doing wrong?

RockfordLhotka replied on Wednesday, November 15, 2006

You are handling the event behind the grid, and calling DataBind() on the detailsview?

georgeb replied on Thursday, November 16, 2006

I handle the following events

Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles DetailsView1.ItemInserted

MultiView1.ActiveViewIndex = Views.MainView

Me.MultiView1.DataBind()

End Sub

Protected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs) Handles DetailsView1.ItemUpdated

MultiView1.ActiveViewIndex = Views.MainView

Me.MultiView1.DataBind()

End Sub

 

georgeb replied on Thursday, November 16, 2006

Protected Sub EditSubscriberButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles EditSubscriberButton.Click

Me.DetailsView1.DefaultMode = DetailsViewMode.Edit

Me.MultiView1.ActiveViewIndex = Views.InsertView

Me.MultiView1.DataBind()

End Sub

You were right I was missing the DataBind command!!

This solves the problem for the first page of gridview. When I change the page then I get the first pages selection displayed in the details view. Any suggestions?

rob123 replied on Wednesday, November 15, 2006

Are you using session caching?  If so, are you clearing the cache?

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!Page.IsPostBack)

        {

            Session["currentObject"] = null;

        }

        //etc.

    }

 

georgeb replied on Thursday, November 16, 2006

I am cleaning the cache but I don't think that this is the problem. 

Copyright (c) Marimer LLC