Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Wednesday, March 28, 2012

UpdatePanel - DataGrid - Client Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

hello.

an easy way to do this is to add a dummy button and then perform a click programatically on that button. this should be enough to force the postback. you can also take a look at the postbackaction or event call the _dopostback method directly.


That Works fine
Thanks Madeira  
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

That Works fine
Thanks Luis Abreu
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

Does this only work from within the update panel?

I'm trying it from outside the panel and it is refreshing the whole page.

UpdatePanel - Javascript Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

I think this is possible. I've got the initial idea fromhere.
So put a hidden div into the UpdatePanel, for example:

<div style="display:none;">
<asp:Button id="btnHidden" runat="server" OnClick="btnHidden_Click" UseSubmitBehavior="false" /></div>

Then "trigger" this button in your popup window from javascript:

var refreshHelper = window.opener.document.getElementById( "btnHidden" );
refreshHelper.click( );

It works for me, but maybe there is smarter solutions than this.

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.


Luis Abreu:

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.

Luis (or anyone else), can you provide an example of using postback action? I'm trying to accomplish something very similar and the dummy button approach doesn't appeal to me.

-Lee


hello.

well, the dopostback action (or, if you want to use javascript, the __doPostBack method) will only work out correctly if there's a control placed inside the form which will be considered responsible for the postback.


Hi Luis,

I do have a a DropDownList that is inside the form so I that would work. I suppose I could just call the __doPostPack method, but I was hoping there would be something that was specific to ATLAS that would force the UpdatePanel to refresh.


hello again,

well, i guess that the answer is no, there isn't. and the reason is simple too: the update panel is just a delimiter that identifies a region which will be refreshed dinamically. all the partial postbacks are controlled by the pagerequestmanager object which uses the updatepanels defined on the page (normally divs or spans) to decide if it should perform a partial or a complete postback.


Ok, so what would you say would be the best way to accomplish this? It sounds as though the options are limited to the dummy button approach or explicitly calling __doPostBack.

hello again.

yep, that's it. i think that currently, there's no other option to perform that kind of operation.

Wednesday, March 21, 2012

UpdatePanel and GridView

I have a GridView that updates a FormView, ive now added the UpdatePanel around the FormView.

When I select a row from the Gridview the FormView Displays the details inside the FormView..great, but......

I have paging enabled on the Gridview so when I click page 2 i dont see the new list in the GridView, how do I fix this?

<-- GridView1 -->

<

MsAjax:ScriptManagerid="ScriptManager"runat="server"EnablePartialRendering="true"/><MsAjax:UpdatePanelID="ID1"runat="server"><ContentTemplate>

<--FORMVIEW -->

</

ContentTemplate>

<Triggers>

<MsAjax:AsyncPostBackTriggerControlID="GridView1"EventName="RowCommand"/>

</Triggers></MsAjax:UpdatePanel>

Hi

Putting UpdatePanel around formview should not effect GridView's Paging. If you have paging enabled it should display you the next records in the table. Does it actually select the page No. 2. or it stays on 1.

Amit


If you want to see the updated list (from the FormView), you must put the GridView also in a UpdatePanel.
Can be in the same UpdatePanel where the FormView is in, or in a new UpdatePanel.
If he's in a other Updatepanel, be sure to attach a trigger to the FormView to it.

(i'm not sure if this is what youre problem was, but you never know..)

UpdatePanel and GridView Problem.(selectedindexchanged doesnt work!)

Hi everyone, I've ran into an updatepanel problem. In my GridView I have a select button which takes the selected row info and puts it into a FormView. I put the Gridview inside an UpdatePanel but now when I click on the select button, no info goes to formview. However without the updatepanel it works ok. Does anyone know why this happens. I include the code below and the formview is just a simple formview.

<ajax:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:GridViewID="GridView1"runat="server" AutoGenerateColumns="False"DataKeyNames="ID"DataSourceID="ap"OnDataBound="GridView1_DataBound" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" >

<Columns>
<asp:BoundFieldDataField="Class"/>
<asp:BoundFieldDataField="Sector"/>
<asp:BoundFieldDataField="Name"/>
<asp:CommandFieldButtonType="Image"SelectImageUrl="~/images/extras/preview.png"ShowSelectButton="True"/>
</Columns> </asp:GridView>
</ContentTemplate>
</ajax:UpdatePanel>

<asp:SqlDataSourceID="ap"runat="server"ConnectionString="<%$ ConnectionStrings: ConnectionString%>"
SelectCommand="SELECT * FROM group >
</asp:SqlDataSource>

ProtectedSub GridView1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles GridView1.SelectedIndexChanged

FVTransaction.ChangeMode(FormViewMode.Insert)
Dim ClassAsString = GridView1.SelectedRow.Cells(0).Text
Dim SectorAsString = GridView1.SelectedRow.Cells(1).Text
Dim NameAsString = GridView1.SelectedRow.Cells(2).Text

Dim PClassAs TextBox =CType(FVTransaction.FindControl("FVClass"), TextBox)
Dim PSectorAs TextBox =CType(FVTransaction.FindControl("FVSector"), TextBox)
Dim PNameAs TextBox =CType(FVTransaction.FindControl("FVName"), TextBox)

PClass.Text = Class.ToString
PSector.Text = Sector.ToString
PName.Text = Name.ToString

EndSub

Thanks for your help.

wow, your formatting makes it really hard to keep track of where stuff is...I couldn't find the formview on there.

anyway, if I had to guess, i'd say that your formview isn't in an updatepanel. Try putting it in one (the same or different, shouldnt' matter) and that should do the trick.


sorry for the formatting, when I paste it, it looked great but then I don't know what happened. I fixed it now.

For your question, Unfortunatelly I can't have the formView inside the same panel as GridView because of the page design template. Is there an another work around?

Thanks


Thank you for your suggestion. I thought I need to have the GridView and FormView in the same updatepanel. But When I put formview another updatepanel, it worked.

Thanks


Glad I could help.

UpdatePanel and MultiView

I use the new MultiView in a form for making customer reservations. The first panel contains a GridView used to select the customer. The OnSelectedIndexChanged event fills the customer info on the reservation page and then switches to that page of the MultiView. This worked just fine until I added Partial Page Rendering to the GridView using the UpdatePanel. The AJAX is terrific as far as refreshing the grid. I have an alphabet selector at the top of the screen and also a TextBox with associated button to search for specific text. This all works great with AJAX. I only have the grid inside of the UpdatePanel and I have ChildrenAsTriggers set to false. The triggers are specified as the events of the search button and the alphabet selector change event.

Here's the problem. In the AJAX version, when the Select LinkButton on the grid is clicked, the screen stays static - just the first time it's clicked. When clicked the second time, the process continues and functions correctly. If I turn on trace, I can see that the code in the OnSelectedIndexChanged event is executed - up to a point, but then it just stops and the screen remains showing the grid. No error is thrown. I suspect it deals with the MultiView, but I don't understand why it works on the second click.

Environment Notes: EnableEventValidation is set to false in the page declaration. If it is set to true, the the OnSelectedIndexChanged causes an error to be thrown. ChildrenAsTriggers is set to false. I'm using the Beta 2 release and the Nov CTP. I am using a MasterPage, but the ScriptManager is in the content page.

Does anybody have any clues as to this behaviour.

Try to setChildrenAsTriggers="false"and UpdateMode="Conditional"in asp:UpdatePanel.
Maybe debug is the best way to fix the problem.
Try to refer to the?following links?to?debug?client?javascript for reference.
Fiddler http://www.fiddlertool.com

Jasson,

Thanks for your reply. I have tried setting ChildrenAsTriggers to false and UpdateMode has always been conditional. After more research, I am thinking that my issue has to do with a user control (the alphabet selector) that I have on the page. Using trace, just after the call to change the index of the MultiView, the code jumps to the constructor of the user control and then immediately stops running and just shows the original view. I have tried to programatically Dispose of the user control and even got a reference to it and set it to null but I have the same reaction. Ironically, the second time the Select link button is pressed, the process continues correctly.

Here is another strange issue - on a different form. I have a RadioButtonList whose SelectedIndexChanged event is a trigger for an UpdatePanel. If I pre-set the value of the RadioButtonList when I populate it using either SelectedIndex = 0; or by using ButtonList.Items[0].Checked = true; then that specific button of the list does not fire the AutoPostBack when clicked. All the others do. If I don't pre-set any buttons, then they all work fine. The RadioButtonList is not inside the update panel but it is identified as a trigger in the triggers tag of the panel.

I don't think MS AJAX extensions are ready for prime-time yet.

R. Harrold


Yeah, I ran into the RadioButtonList problem and spent ridiculous amount of time to figure it out till I saw your post. I cannot believe AJAX has been shipped with such issue.

I am having a problem with the MultiView inside an UpdatePanel, The multi view has 2 views with buttons on each...

When clicking on the button contained inside the second view (when the 2nd view is active) an error mesage box is displayed (javascript client error) stating that: 'null' is null or not an object. I am not trying to fix the error on the client side (i know what null is and how to validate it). But rather is there a way to fix this on the server side maybe an option used with the UpdatePanel control ?


I think I got the problem, The button on the second view is simply a "continue" button meaning it just forwards client to another page.

Since the error was on the client side, the problem I think was solved by setting:CausesValidation="false" for the button.