Showing posts with label gridview. Show all posts
Showing posts with label gridview. Show all posts

Monday, March 26, 2012

Trigger a ModalPopupExtender from LinkButton in a column on a GridviewRow

Hi,

Has anyone got any sample code for using a linkbutton in gridview as the targetcontrol for a modalpopupextender. I have tried several ways but it seems the clientsideid is only temporary since it won't using it.

Any ideas or thoughts in this will be helpful.

Frederik

If you create on Modal Popup Control outside of the gridview and point it at a dummy button (which you can hide), then you can find the modal popup from client side code (called by your linkbutton) using $find(), and then call the modal popup's show() method to get it to pop-up.


I am guessing that you probably want to load up the modalpopup with content related to a row in the grid. In this case, you might want to postback to the server, load the content and then show the modalpopup by calling the Show() method all from code behind. You will still need to use a dummy button as outlined by skirkland so that you can programmatically control the modalpopup visibility.

trigger for control that is dynamically created on databind

I have a dropdownlist that is created when the gridview is databound. This is because the dropdownlist is contained in the headertemplate of a templatefield column. So I have tried to add the trigger dynamically right after the gridview is databound, but I keep getting an error saying that the controlID wasn't found...I don't know what is wrong. I can find the control inside the the gridview with no problem using the findControl fuction.


TimeStampGridView.DataBind();
DropDownList StatusFilterDLL=(DropDownList)TimeStampGridView.HeaderRow.Cells[2].FindControl("StatusFilter");//finds the Control
StatusFilterDLL.SelectedIndex = StatusFilterDLL.Items.IndexOf(StatusFilterDLL.Items.FindByText(StatusFilter));//Works fine
AsyncPostBackTrigger trigger =new AsyncPostBackTrigger();
trigger.ControlID ="StatusFilter";
trigger.EventName ="SelectedIndexChanged";
GridUpdatePanel.Triggers.Add(trigger);//error:A control with ID 'StatusFilter' could not be found for the trigger in UpdatePanel 'GridUpdatePanel'


Anyone know what I'm doing wrong here?

Thanks for the help in advance!

I removed all the code for the dynamic trigger and set the dropdownlist's autopostback= true so now when the user changes the selectedindex the gridview is updated

Trigger not working for Linkbutton in GridView

I have a linkbutton I'm trying to add a trigger two for two update panels on my aspx page.

I have this but the update panels are not updating... any recommendations?

protected void GridView_ChangeSearchResults_RowDataBound(object sender, GridViewRowEventArgs e) {if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lb = (LinkButton)e.Row.FindControl("Linkbtn_StaffChangeNew"); AsyncPostBackTrigger trigger =new AsyncPostBackTrigger(); trigger.ControlID = lb.UniqueID.ToString(); trigger.EventName ="Command"; UpdatePanel_Header.Triggers.Add(trigger); UpdatePanel_Info.Triggers.Add(trigger); } }

It doesn't bomb out on me and I've put in a breakpoint and is seems to be adding the triggers but they don't fire for some reason. When I add the triggers in from the GUI I'm using the onlcick event for other button controls on the page.

For this action I am using a command event. I've tried changing the EventName to both Click and Command and neither seem to work. Here is the method for the command event.

protected void ChangeStaffFromGrid(object sender, CommandEventArgs e) {int userStaffID = Convert.ToInt32(bmsUser.CmsStaffID);string budgetyear = Convert.ToString(budgetYear.UserSelectedFiscalYear);
int profileID = Convert.ToInt32(Session["staffProfileID"]);int newProfileID = 0;int newStaffID = Convert.ToInt32(e.CommandArgument);//sets the new staff ID from the selection. Hashtable changeStaffHash =new Hashtable(); changeStaffHash = BmsDLL.ChangeStaff(profileID, newStaffID, userStaffID); newProfileID = Convert.ToInt32(changeStaffHash["newStaffProfileID"]); SetUserSessions("change", newProfileID); SetHeaderInfo(Convert.ToInt32(Session["staffProfileID"])); SetNewProfileIDItems(Convert.ToInt32(Session["staffProfileID"])); }

The two methods that update the two pannels are SetHeaderInfo and SetUserSessions.

Thanks for your help.

Use ScriptManager1.RegisterAsyncPostBackControl(YourLinkButton) instead of creating AsyncTrigger. then in the button command event update your update panels by calling the update.


I've just recenlty started using Ajax in my app, do you have a code example of your suggestion?

Which even would I add ScriptManager1.RegisterAsyncPostBackControl(YourLinkButton) ? In the rowdatabound event?


Try the following code:

protected void GridView_ChangeSearchResults_RowDataBound(object sender, GridViewRowEventArgs e){if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lb = (LinkButton)e.Row.FindControl("Linkbtn_StaffChangeNew");ScriptManager1.RegisterAsyncPostBackControl(lb);// Assuming the ScriptManager name in your page is ScriptManager1 }}

That didn't work. The same updates to the panels are working with regular buttons. This makes no sense.


Hi,

As far as I know,You can add anUpdatePanel control programmatically, but you cannot add triggers programmatically. To create trigger-like behavior, you can register a control on the page as an asynchronous postback control. You do this by calling theRegisterAsyncPostBackControl(Control) method of theScriptManager control. You can then create an event handler that runs in response to the asynchronous postback, and in the handler, call theUpdate() method of theUpdatePanel control.

For more information,seehttp://www.asp.net/AJAX/Documentation/Live/mref/T_System_Web_UI_UpdatePanel.aspx

IfRegisterAsyncPostBackControl(Control) method & Update() method doesn't work, there must be something wrong in your code.You can post some code so we can check out where is the error.

Best Regards


It seems the Update() method is working for me. Thanks for your help.

Saturday, March 24, 2012

Trigger PostBack to an UpdatePanel from a separate UserControl?

Hi,

I like putting stuff in separate usercontrols, since i do a lot of gridview templatefields and putting several of these gridviews in one page messes up my .aspx. with user controls, i can just worry about the layout and design on my .aspx pages.

i have one problem though with my new personal approach,

example is i created a "Picture Gallery" site:

1. I put a FileUpload Control (which does NOT work in an UpdatePanel), a button that contains upload tasks (save file, add records to sql db), and an SQLDataSource control, in an AjaxControlToolkit ModalPopup. I then put them all in a UserControl, ill call it Upload.ascx.

2. I create another UserControl, which i shall call Gallery.ascx. This contains a DataList control, that displays the pictures and relative info from the sql db. DataList is connected to an SQLDataSource control. I put them in an UpdatePanel, so i can add an UpdateProgress control.

3. I then put Upload.ascx and Gallery.ascx in my Default.aspx

Ok it works fine, File uploads, records get inserted to the sql database, ModalPopup works! I have one major problem though, everytime I press the Upload Button from Upload.ascx, I need to call DataList.DataBind() from Gallery.ascx's Page_Load event, or simply UpdatePanel.Update(), since it will cause Page_Load to fire from Gallery.ascx UserControl. How do I do this?

Hi,wreck_of_u

We have a few cases were we use a button on our pages that aren't visible, and they are being programatically clicked to refresh our page.

Do it like this:

PageA.aspx:

<%@. Page Language="C#" %>

<%@. Register src="http://pics.10026.com/?src=Gallery.ascx" TagName="Gallery" TagPrefix="uc1" %>
<%@. Register src="http://pics.10026.com/?src=Upload.ascx" TagName="Upload" TagPrefix="uc2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Upload1.Button1clientID = Gallery1.Button1clientID;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

</div>
<uc1:Gallery ID="Gallery1" runat="server" />
<uc2:Upload ID="Upload1" runat="server" />
</form>
</body>
</html>

Gallery.ascx:

<%@. Control Language="C#" ClassName="Gallery" %>

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)
{
}

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}

public string Button1clientID
{
get
{
return Button1.ClientID;
}
}

</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<div style="visibility:hidden"><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" UseSubmitBehavior="false" Text="Button" /></div>
</ContentTemplate>
</asp:UpdatePanel>

Upload.ascx:

<%@. Control Language="C#" ClassName="Upload" %>

<script runat="server">
private string buttonclientID = "";
public string Button1clientID
{
set
{
buttonclientID = value;
}
}
</script>

<script type="text/javascript">
function submitForm(frameName,upload){
// document.forms[0].action="PageA.aspx"
// document.forms[0].target=frameName;
// window.setTimeout(function(){
// var uploadE=document.getElementById(upload);
// uploadE.parentElement.appendChild(document.createTextNode(uploadE.value));
// uploadE.parentElement.replaceChild(uploadE.cloneNode(true),uploadE);
// },100);
// document.forms[0].submit();
document.getElementById("<%=buttonclientID %>").click();
}
</script>

<div id="Div1">
<input type="file" name="upload" id="upload" />
<button onclick="javascript:submitForm('hiddenFrame','upload')">Upload</button>
<iframe name="hiddenFrame" src="http://pics.10026.com/?src=blank.htm" id="hiddenFrame" style="display: none">
</iframe>
</div>

I have used this mothod to fix some problems :

http://forums.asp.net/t/1117770.aspx

http://forums.asp.net/t/1115934.aspx

http://forums.asp.net/t/1116851.aspx

You can also see these threads for more help.

Let me know if you need more info.

If this help you,don't forget mark it as a answer.Thanks!

An Ajax Alternative for FileUpload!!!!

We've all embraced Ajax as a revolutionary technology, but many of us forget (or are not aware) of asynchronous posts in the times before XmlHttp requests. Our good old friend the IFrame used to be the preferred option for asynchronous http communications. Because an iframe is in essence it's own browser window, it can be used to fire off asynchronous requests (both POST and GET). However, even more important is an IFrame's ability to be a 'target' of a form POST. By adding an IFrame to the page and setting it as the target of the form post, you can in essence create an asynchronous file transfer.

For more help about Ajax Alternative for FileUpload, Please check: http://blogs.infragistics.com/blogs/tony_lombardo/archive/2007/04/09/file-uploads-where-s-the-ajax.aspx


You can see this post

http://forums.asp.net/p/1123812/1770607.aspx#1770607


Hi, This is a great technique.


But it does not work for me in Firefox. Does it work for you in FF? works fine in IE7

Trigger set to a userControl controls event

Hi Everyone,

I am pretty new to atlas and I am trying to figure out if it can do what i want it to do. I have a gridview control and a user control on a page. The user control has a button that I would like to have trigger the update panel on the aspx webform for the gridview.

When I do this I get a control ID not valid exception on the page. Is there a way to do this or am i only dreaming of better days?

Thanks

Calvin X

Is this not possible or nobody knows?

Were you able to figure this out? I am contemplating performing the same task, so I am interested if you have had some success.

Thank you!

trigger update panel without using controls

I have a bunch of links which I generate as a string and output to a label control. (its a database generated tag cloud). I want to update a gridview in an update panel when one of these tags/links is clicked. All these links exist outside of the update panel. How do I trigger such an update on the update panel??

Thanks in advance!

Andles

Hey Anderloo

I think these forum threads have the answer your looking for

http://forums.asp.net/thread/1645424.aspx

Trigger UpdatePanel with javascript

I have a GridView inside an UpdatePanel. Also on the page is a button, that when the user clicks opens up a modal dialog box. After the user selects an item from the dialog box, the dialog closes which triggers a javascript function. The purpose of this javascript function is to re-bind the GridView, thereby displaying the item just selected from the dialog box.

The javascript function simply triggers a hidden linkbutton that also resides inside the UpdatePanel.

The javascript code:

document.getElementById('ctl00_Main_LinkButton1').click();

The LinkButton code:

ProtectedSub LinkButton1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles LinkButton1.Click

GridView1.DataBind()

EndSub

This all works fine under IE6. The problem just started when I upgraded to IE7. The LinkButton is no longer getting triggered, so the GridView doesn't update. I've tried this with both the Atlas release, and the Ajax Beta 2 release. Neither seems to do what I want with IE7.

One other thing, if I remove the UpdatePanel from the page entirely, and force a full page refresh, it works fine with IE7.

Has anyone else noticed this? Any ideas on a work around?

hello.

try using fiddler to see the error you're getting.


I downloaded and ran Fiddler, but can see no errors.

I have many apps that use the similar method, and it works in IE6, IE7 and Firefox v2.0 and Apple Browser (don't remember the name - Safari?) hmmm who cares.

Try put your LinkButton outside the update panel.

WS

p.s: my apps use button instead link button. AND I don't use modal window, because it's not supported by many browsers. Instead, I use floating div. Good Luck.


I think the key difference with your solution is that all the logic resides in one page (with the use of floating div). I have tried adding a linkbutton outside the updatepanel, but this makes no difference in my solution.

With the modal dialog, I can trigger the javascript function when the dialog is closed. I tested this my triggering an Alert from my javascript function, so I know the function is being called when I close the dialog.

I next tried adding an HTML Input button outside the updatepanel:

<inputid="Button1"type="button"value="button"onclick="javascript:document.getElementById('LinkButton1').click();"/>

When I clicked this button, itdid trigger a refresh. I'm just not sure why it won't do it automatically once the dialog box is closed. Again, I've proven that the function is being called when the dialog is closed. I'm wondering if this isn't some IE 7 security issue. I've played around with the permissions a bit, but still have no joy.


For what it's worth,

I finally found a solution to my problem. I did a little digging into the JS file for the AJAX ModalPopup control, and modified my javascript accordingly:

window.setTimeout(

"document.getElementById('ctl00_Main_LinkButton1').click();", 0);

Now works with both IE6 and IE7.

Thanks to all for your responses.

Trigger updatepanel update from a nested gridview

Hello,

I've got a DataList (Categories) that has a nested GridView (Sub-Categories) in its ItemTemplate. The GridView has a ButtonField (command name = "Select") that, when clicked, I would like to have update an UpdatePanel elsewhere on the page (which will show items within the selected Sub Category). The Sub Categories GridView is created in the ItemDataBound event of the Categories DataList. The problem I'm running into is that when the GridView's SelectedIndexChanged event is fired, the entire page is refreshed instead of just the UpdatePanel.

The UpdatePanel is set up with an UpdateMode of "Conditional" and no triggers are set up declaratively. In the DataList's ItemDataBound event, I'm creating and populating the GridView controls and am setting the UpdatePanel's triggers:

GridView grdItems = (GridView)e.Item.FindControl("grdItems");if (grdItems !=null){ grdItems.DataSource = ; grdItems.DataBind(); AsyncPostBackTrigger trig =new AsyncPostBackTrigger(); trig.ControlID = grdItems.UniqueID.ToString(); trig.EventName ="SelectedIndexChanged"; pnlRight.Triggers.Add(trig);}

Then, in the GridView's SelectedIndexChange event, I query the database and set all of the control values in the UpdatePanel and call the UpdatePanel's Update() method. Is there a piece somewhere that I'm missing that will keep the entire page from posting back? Thanks in advance for your help!

One more thing I noticed: it looks like the first time I click an item in the GridView, the UpdatePanel updates correctly. It's only on subsequent GridView events that the entire page is posted back.

Hi,

Please note that:

Programmatically addingAsyncPostBackTrigger controls is not supported. Use theRegisterAsyncPostBackControl(Control) method of theScriptManager control to programmatically register a postback control, and then call theUpdate() method of theUpdatePanel when the control posts back.

http://asp.net/ajax/documentation/live/mref/T_System_Web_UI_AsyncPostBackTrigger.aspx


Thanks Raymond! By making the changes you mentioned and by calling theRegisterAsyncPostBackControl method in the GridView's init method (instead of the parent control's ItemDataBound method), everything is working like it should!

-Brian

Trigger wont cause a PostBack (Inside UpdatePanel)

When I click my LinkButton inside my GridView I want the page to postback and a pdf to be streamed to the browser.
It is streamed but the page dont Post so nothing is received.

What am I doing wrong here?

1Protected Sub GridView1_RowDataBound1(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.GridViewRowEventArgs)Handles GridView1.RowDataBound23If e.Row.RowType = DataControlRowType.DataRowThen45Dim ptAs New PostBackTrigger()67pt.ControlID = e.Row.FindControl("lbtnPrintInvoice").UniqueID8UP1.Triggers.Add(pt)910End If1112End Sub

Hi,

in docs:

http://asp.net/AJAX/Documentation/Live/mref/T_System_Web_UI_PostBackTrigger.aspx

Remarks

Use thePostBackTrigger control to enable controls inside anUpdatePanel to cause a postback instead of performing an asynchronous postback.

Use theRegisterPostBackControl(Control) method of theScriptManager control to programmatically register a postback control. You can then call theUpdate() method of theUpdatePanel control when the trigger control performs a postback.

note

Programmatically addingPostBackTrigger controls is not supported.

So basically you need to use ScriptManager's RegisterPostBackControl method to do it.


Hmm I can apreciate that but how do I call my lbtnPrintInvoice inside Gridview1 thats the question... The below code doesnt work for some reason ;)

1<Triggers>2<asp:PostBackTrigger ControlID="lbtnPrintInvoice" />3</Triggers>

Gives the error:

A control with ID 'lbtnPrintInvoice' could not be found for the trigger in UpdatePanel 'UP1'.


You really read the previous reply?Big Smile

Does this help:

Protected Sub GridView1_RowDataBound1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then

ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FindControl("lbtnPrintInvoice"))

End If

End Sub

-- EDIT: Fixed this reference in the code


Jeeze! I wans't aware you could actually call the scriptmanager like that since mine is in the masterpage I never thought I could adress it directly

Thanks a bunch for the solution though for people that might want the complete solution I added the page reference in the below code as well.

1Protected Sub GridView1_RowDataBound1(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.GridViewRowEventArgs)Handles GridView1.RowDataBound23If e.Row.RowType = DataControlRowType.DataRowThen4ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FindControl("lbtnPrintInvoice"))5End If67End Sub

Oh and I also tried to do it in RowCreated, never would have worked out.


ScriptManager has good utility methods. It's worth to know about them. I edited & corrected the code. Made a typo as I typed directly to the post.

Triggering an Updatepanel (b) based on a gridview rowcommand which is inside a UpdatePanel

Hi there,

I have two sections on my aspx page which contain two grids on an aspx page. User and UserDetails.

User section has atab control which contains an update panelupUsers which contains the gridviewgvUsers. I have another grid in a different updatepanelupUserDetails this contains a grid toogvUserAccessKeys. I want to refresh the second updatepanelupUserDetails (basically trigger it) based on the RowCommand in the gvUsers which is in the first update panel. I was able to do this till I added the tab control.

Now it cannot find the gvUsers controlID when I write the trigger.

So is it possible to trigger a different UpdatePanel based on a gridview Control rowcommand event from inside a AjaxControlKit tab control.

Thanks in advance for any suggestions.

Rakesh Ajwani

following is the HTML snipped of the aspx page.

</td><tdstyle="width: 100px"valign="top"><cc1:TabContainerID="pTabs"runat="server"ActiveTabIndex="0"><cc1:TabPanelrunat="Server"ID="tabUsers"HeaderText="Users"Enabled="true"><ContentTemplate><asp:UpdatePanelID="upUsers"runat="server"><ContentTemplate><asp:GridViewID="gvUsers"runat="server"AutoGenerateColumns="False"Width="129px"OnRowDataBound="gvUsers_RowDataBound"OnRowCommand="gvUsers_RowCommand"><Columns><asp:TemplateFieldHeaderText="Users"><HeaderTemplate><tablewidth="100%"><tr><tdalign="left"><asp:Labelrunat="server"Text="Users"></asp:Label></td><tdalign="right"><asp:ImageButtonID="ibAddUser"OnClick="ibAddUser_Click"runat="server"ImageUrl="Images/plus-8.png"/></td></tr></table></HeaderTemplate><ItemTemplate><asp:LinkButtonrunat="server"ID="linkbUserSelect"Text='<%#((System.Data.DataRow)Container.DataItem)["LastName"] + " " + ((System.Data.DataRow)Container.DataItem)["FirstName"]%>'CommandName="ViewDetail"></asp:LinkButton></ItemTemplate></asp:TemplateField></Columns></asp:GridView></ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="gvInstitutions"EventName="RowCommand"/></Triggers></asp:UpdatePanel></ContentTemplate></cc1:TabPanel></cc1:TabContainer></td></tr><tr><tdcolspan="2"width="100%"><asp:UpdatePanelID="upUserDetail"runat="server"><ContentTemplate><asp:LabelID="lblInstitution"runat="server"Width="132px"></asp:Label><br/><br/><asp:LabelID="lblLName"runat="server"Width="143px"></asp:Label><asp:TextBoxID="txtLName"runat="server"Width="143px"></asp:TextBox><asp:LabelID="lblFName"runat="server"Width="143px"></asp:Label><asp:TextBoxID="txtFName"runat="server"Width="143px"></asp:TextBox>

<br/><br/><asp:LabelID="lblEmailID"runat="server"Width="154px"></asp:Label><asp:TextBoxID="txtEmailID"runat="server"Width="143px"></asp:TextBox><br/><asp:GridViewID="gvAccessKeys"runat="server"AutoGenerateColumns="False"Width="689px"OnRowCreated="gvAccessKeys_RowCreated"OnRowDataBound="gvAccessKeys_RowDataBound"><Columns><asp:TemplateFieldHeaderText="Application"><ItemTemplate><asp:LabelID="lblApplication"runat="server"Visible="true"Text='<%#((System.Data.DataRow)Container.DataItem)["ApplicationCode"]%>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="Institution"><ItemTemplate><asp:LabelID="lblCampus"runat="server"Visible="true"Text='<%#((System.Data.DataRow)Container.DataItem)["InstitutionName"]%>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="Role"><ItemTemplate><asp:DropDownListID="ddRole"EnableViewState="true"runat="server"></asp:DropDownList></ItemTemplate></asp:TemplateField></columns><EmptyDataTemplate><tablewidth="100%"><tr><tdalign="left">Access Keys</td></tr><tr><tdcolspan="2"><asp:LabelID="lblNoUCARData"runat="server"Text="No Soup For You"Width="217px"></asp:Label></td></tr></table>

</EmptyDataTemplate></asp:GridView><asp:ButtonID="btnSave"runat="server"Text="Save & notify"OnClick="btnSave_Click"/></ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="gvUsers"EventName="RowCommand"/></Triggers></asp:UpdatePanel></td></tr>

Hi,

I have a similar problem, except that I am loading UserControls with GridView dynamically into the TabPanels. The GridView have buttons that should fire RowCommand. The TabContainer is within an UpdatePanel. My RowCommand event is not firing, did you find any solutions to your problem?

Thanks.


Hook the gvUsers RowCreate Event, Find the Button using the FindControl. Once Found, create asyncpostbacktrigger programatically set the control id to the found button id and add the trigger in the second update panel trigger collection.

Trigger-Problem with GridView RowCommand

Hello,

I've got a Problem after Migrating to the new AJAX.DLL. The Trigger doesn't work for the Gridview anymore.

I set

<asp:UpdatePanelID="udpanel"runat="server"UpdateMode="Conditional"ChildrenAsTriggers="true"RenderMode="Inline">

<ContentTemplate>

<asp:Gridview ... />

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlID="gview"EventName="RowCommand"/>

</Triggers>

</asp:UpdatePanel>

The RowCommand-Event in the Codebehind doesn't be fired.

Thanks a lot!

Paul

You really do not need to set a AysnchPostBackTrigger on the Event - unless the ChildrenAsTriggers is false (default is true) then everything is already thrown into the update controls collection.

Problems arise when you duplicate triggers as it will remove both of them if they have the same ref I believe...

Wednesday, March 21, 2012

Trouble trying to use PostbackTrigger with FileUpload in UpdatePanel

Scenario: I have 2 UpdatePanels, 1 containing a GridView (master) and the other containing a DetailsView (child). The DetailsView has an AsyncPostBackTrigger for the GridView's SelectedIndexChanged event. I use a CommandField with ShowEditButton in the DetailsView. The DetailsView is in Edit mode by default. One of the fields in the DetailsView contains a FileUpload. In the ItemCreated event, I register the auto generated "Update" LinkButton as a PostBackControl. I have also tried adding a PostBackTrigger to the UpdatePanel, but neither attempt results in the FileUpload.HasFile property being true.

1Protected Sub dv_ItemCreated(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles dv.ItemCreated2Dim linkAs LinkButton =Nothing3 Dim triggerAs PostBackTrigger =Nothing4 If Not dv.FooterRowIs Nothing Then5 Dim commandRowIndexAs Integer = 06Dim commandRowAs DetailsViewRow = dv.Rows(commandRowIndex)7Dim cellAs DataControlFieldCell =CType(commandRow.Controls(0), DataControlFieldCell)8For Each ctlAs ControlIn cell.Controls9If TypeOf ctlIs LinkButtonThen10 link =CType(ctl, LinkButton)11Else : link =Nothing12 End If13 If Not linkIs Nothing Then14 If link.CommandName.Equals("update", StringComparison.CurrentCultureIgnoreCase)Then15'trigger = New PostBackTrigger16 'trigger.ControlID = link.ClientID17 'upDV.Triggers.Add(trigger)18 ScriptManager.GetCurrent(Me).RegisterPostBackControl(CType(link, Control))19End If20 End If21 Next22 End If23 End Sub
The page does do a full postback when the Update button is hit, so at least that works. I'm assuming that HasFile is false for the first Update because the Update button is not registered with the ScriptManager when the page is loaded. After an update, page is loaded with the control registered as a PostBackControl, thus making subsequent updates work fine. Assuming that this is correct, is there anyway to do this? My reasoning in this assumption is that if I select a row in the GridView by default such that when the DetailsView is first loaded into the page, it has a record as opposed to the EmptyDataText being shown, everything works as expected. Is there a way to use this functionality without having a record in DetailsView before the user actually selects a record?

Kind of funny that this works at all. The PostBackTrigger is supposedly not capable of being added programatically based onthe docs.

Ryan Pedersen
MCP


According to the documentation for AJAX the FileUpload control is not supported.

There are several work around available on this forum.

trying to add a popup/tooltip to an updatepanels gridview item

Hi everyone,

I have a Gridview that I want to place inside an update panel, but the current javascript tooltip calls bomb out. These calls are created dynamically (some results have the popup, others don't) and store text helping to explain the search results. Can someone lead me in the direction of what I need to be doing here or the control needed to make it work?

Try to take a look at the following links about javascript tooltip for reference.
http://www.walterzorn.com/tooltip/tooltip_e.htm#download
http://www.webreference.com/js/column16/
http://www.dustindiaz.com/sweet-titles
http://javascript.internet.com/generators/dhtml-tooltip-generator.html
http://tooltip.crtx.org/
Wish the above can help you.