Showing posts with label populates. Show all posts
Showing posts with label populates. Show all posts

Monday, March 26, 2012

Updating DataGrid control with ajax

Hi,

First post here (hope it's in the right forum)-go easy on me-I'm new to ajax!

Okay, so I have a control, which populates a datagrid, given two values (from seperate controls). Basically I want to make it so that pressing the update button will reload just the function that fills the datagrid and not the whole page, if you see what I mean.

I think I need to be using an update panel but the server side end is confusing me.

Thanks

The easiest way is going to be, put your Datagrid (I think you mean gridview) and your button inside an update panel.

Wire the buttons onclick event up to to just redatabind the grid. Here's an example: This example uses an unbound gridview, because I dont have any data currently to bind one too, but you'rs would be bound and work the same.

 <asp:UpdatePanel ID="update1" runat="server" UpdateMode="conditional" ChildrenAsTriggers="true"> <ContentTemplate> <asp:GridView ID="gv1" runat="server"> </asp:GridView> <asp:Button ID="button1" runat="server" Text="Update Grid" OnClick="button1_Click" /> </ContentTemplate> </asp:UpdatePanel>

Protected Sub button1_Click(ByVal senderAs Object,ByVal eAs System.EventArgs) gv1.DataBind()End Sub
Give it a shot, if you run into problems, post back and let us know, we can help you further.


Sorry I havent replied sooner, I've been having problems populating my gridview. I'll come back and look at it once I have the function that takes the two values and returns the dataset :)

Saturday, March 24, 2012

UpdatPanel and Session Variable

I have a treeview which populates a session variable when treeview items are selected. The session variable in turn is used to create a datatable. I have the datatable inside of an updatePanel and the trigger is the selectednodechanged event of the treeview. All of this works great. However, while the Session variable and resulting datatable are updated within the updatepanel the session variable is not updated/current when accessed by other controls/methods (that is- none of the treeview items placed inside of the session variable are there). Without the updatePanel changes to the session variable are "global" and seen by other callers. Is there any way to make the changes to the session variable that occur inside of the updatepanel "global"? Is there a way to place the session variable inside of the updatepanel?

Thanks in advance for any help or advice.

Hi rudolph41,

You should ask your question in the"Atlas" Discussion and Suggestions forum because that's where all theUpdatePanel experts are.

Thanks,
Ted