Using Web Parts and DataBinding across Web Parts with Ajax Update Panels.

Sorry in advance if this is better suited to the data presentation controls forum, but I'm not having a problem there, it's unique to web parts.

 

OK, I have two different Web User Controls (.ascx files) that have GridViews on them. They're all wrapped with Ajax update panels, so when a new row is added or an existing row is edited, etc. it's not a full postback. Great, looks awesome.

Here's my issue, hopefully someone has run into this before. Let's call the Gridviews GV_A and GV_B. When I add a new record to GV_A, the database creates a new ID for the record behind the scenes. In GV_B, I have a drop down list that's populated by all of the IDs listed in GV_A. If I add a new record in GV_A, I want GV_B to databind without having to do something in the GV_B web part like edit, etc.(which re-connects it asynchronously). What I need is a DataBind() event to fire any time something happens *within* a web part. Is this done with connection contracts? OR is there just something I need to add to the code behind (I'm i C# btw) that takes care of this? Sorry if I'm not being clear, let me know where I'm foggy.

 

Thanks 

 
 

0
fisherman961
2/21/2008 10:09:03 PM
asp.net.personalization 3779 articles. 0 followers. Follow

6 Replies
977 Views

Similar Articles

[PageSpeed] 32

Hi fisherman961,

You said "When I add a new record to GV_A, the database creates a new ID for the record behind the scenes". Can you post the code where you configure your GV_A to work with database? That way I may be able to tell you how and when to repopulate the GV_B.

Regards,
Sasa


http://www.vegaitsourcing.rs
http://www.codeplex.com/aspnetlibrary
0
Sasa
2/22/2008 8:54:40 AM

I'll simplify it for brevity's sake..

Here's one of the ascx files:

 

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Bids.ascx.cs" Inherits="Fooweb.Bids" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<asp:UpdatePanel ID="Panel_Bids" runat="server">
     <ContentTemplate>
        <asp:GridView ID="GV_Bids" runat="server" DataSourceID="ODS_Bids" 
            AutoGenerateColumns="False" ShowFooter="True" 
    OnRowCommand="GV_Bids_RowCommand" DataKeyNames="guid" 
            onrowupdating="GV_Bids_RowUpdating" >

            <Columns>
                <asp:CommandField ButtonType="Button" ShowEditButton="True" />
                <asp:TemplateField HeaderText="Doc ID" SortExpression="Doc_id">
                    <EditItemTemplate>
                          <asp:DropDownList ID="DDL_Bid_E_DocID" runat="server" DataSourceID="ODS_Docs" 
                            DataTextField="Doc_id" DataValueField="guid">
                        </asp:DropDownList> 
                       <asp:ObjectDataSource ID="ODS_Docs" runat="server" 
                       OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                       TypeName="Fooweb.FoosTableAdapters.id_Foo_DocsTableAdapter" >
                       <SelectParameters>
                           <asp:QueryStringParameter Name="Fooguid" QueryStringField="FooGUID"  />
                       </SelectParameters>
                   </asp:ObjectDataSource>
                   </EditItemTemplate>
                    <FooterTemplate>
                        <asp:DropDownList ID="DDL_Bid_F_DocID" runat="server" DataSourceID="ODS_Docs" 
                            DataTextField="Doc_id" DataValueField="guid">
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="ODS_Docs" runat="server" 
                       OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                       TypeName="Fooweb.FoosTableAdapters.id_Foo_DocsTableAdapter" >
                       <SelectParameters>
                           <asp:QueryStringParameter Name="Fooguid" QueryStringField="FooGUID"  />
                       </SelectParameters>
                   </asp:ObjectDataSource>
                    </FooterTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Doc_id") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                
            </Columns>

            <EmptyDataTemplate>
                <table style="width:100%;">
                    <tr>
                        <td>
                            Doc ID:<asp:DropDownList ID="DDL_Bid_ET_DocID" runat="server" 
                                DataSourceID="ODS_Docs" DataTextField="Doc_id" DataValueField="guid">
                            </asp:DropDownList>
                        </td>
                        <td><asp:Button ID="Button_Bid_New" runat="server" Text="Add" CommandName="AddBidFromEmpty" /></td>
                    </tr>
                </table>
            </EmptyDataTemplate>

            <HeaderStyle BackColor="#3399FF" />

        </asp:GridView> 
        <asp:ObjectDataSource ID="ODS_Bids" runat="server" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
            InsertMethod="Insert" 
            UpdateMethod="Update"
            TypeName="Fooweb.FoosTableAdapters.id_Foo_bidsTableAdapter" >
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="" Name="Fooguid" 
                QueryStringField="FooGUID" />
        </SelectParameters>
            <UpdateParameters>
            <asp:Parameter Name="guid" Type="Object"/>
            </UpdateParameters>
        </asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>
 
----------------------
Code Behind:
----------------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

namespace Fooweb
{
    public partial class Bids : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        //Updating the Bids Panel
        protected void GV_Bids_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "AddBidFromEmpty")
            {
                string DocID = ((DropDownList)GV_Bids.Controls[0].Controls[0].FindControl("DDL_Bid_ET_DocID")).SelectedValue;
                ODS_Bids.InsertParameters.Add("docguid", DocID);
                ODS_Bids.Insert();
            }
            if (e.CommandName == "NewBid")
            {
                string DocID = ((DropDownList)GV_Bids.FooterRow.FindControl("DDL_Bid_F_DocID")).SelectedValue;
                ODS_Bids.InsertParameters.Add("Docguid", DocID);
                ODS_Bids.Insert();
            }

        }

        protected void GV_Bids_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            e.NewValues.Add("Docguid", ((DropDownList)(GV_Bids.Rows[e.RowIndex].FindControl("DDL_Bid_E_DocID"))).SelectedValue);

        }

        protected void BidDel_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["FooConn"].ConnectionString.ToString());
            SqlCommand cmd = new SqlCommand("sp_delete_bid", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            conn.Open();
            Button btn = (Button)sender;
            GridViewRow RowCon = (GridViewRow)btn.NamingContainer;
            String RowVal = GV_Bids.DataKeys[RowCon.RowIndex].Value.ToString();
            cmd.Parameters.Add("@original_guid", SqlDbType.UniqueIdentifier).Value = new Guid(RowVal);
            cmd.ExecuteNonQuery();
            GV_Bids.DataBind();
            conn.Close();
        }
    }
}
-------------------
The WebParts assembler looks like this:
 ---------------------------
<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="DocBrowser.aspx.cs" Inherits="Fooweb.WebForm1"  %>
<%@ register TagPrefix="ID" TagName="Docs" src="~/Docs.ascx" mce_src="~/Docs.ascx" %>
<%@ register TagPrefix="ID" TagName="Bids" src="~/Bids.ascx" mce_src="~/Bids.ascx" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="navContent" runat="server">
    <asp:WebPartManager ID="WPM" runat="server"> 
    </asp:WebPartManager>
      <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <table style="width: 100%; height: 335px;">
        <tr>
            <td style="width: 20%">
                <asp:CatalogZone ID="CatalogZone1" runat="server">
                <ZoneTemplate>
                    <asp:PageCatalogPart ID="PageCatalog" runat="server" />
                </ZoneTemplate>
                </asp:CatalogZone>
            </td>
            <td width="50%">
                <asp:WebPartZone ID="MainZone" runat="server" >                   
                <ZoneTemplate>
                 <ID:Docs runat="server" id="myDocs" title="Docs" /> 
                 <ID:Bids runat="server" ID="Bids" title="Bids" />
                </ZoneTemplate>
                </asp:WebPartZone>
            </td>
            <td width="30%">
                <asp:WebPartZone ID="SideZone" runat="server">
                </asp:WebPartZone>
            </td>
        </tr>
        </table>

</asp:Content>
 -------------------------
with nothing in the code behind file. Obviously, there are stored procedures at the database level, and I've left out one Web Control, the docs.ascx file, but it's essentially the same structure as the bids.ascx file, the difference being that it creates a doc instead of a bid. Make sense?
0
fisherman961
2/22/2008 7:32:55 PM

Hi,

The webparts are not  Compatible with UpdatePanel Controls.

The more you can refer the section of Controls that Are Not Compatible with UpdatePanel Controls of this article: http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx

Hope it helps.


Amanda Wang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Amanda
2/26/2008 6:44:39 AM

fisherman961:

OK, I have two different Web User Controls (.ascx files) that have GridViews on them. They're all wrapped with Ajax update panels, so when a new row is added or an existing row is edited, etc. it's not a full postback. Great, looks awesome.

Here's my issue, hopefully someone has run into this before. Let's call the Gridviews GV_A and GV_B. When I add a new record to GV_A, the database creates a new ID for the record behind the scenes. In GV_B, I have a drop down list that's populated by all of the IDs listed in GV_A. If I add a new record in GV_A, I want GV_B to databind without having to do something in the GV_B web part like edit, etc.(which re-connects it asynchronously). What I need is a DataBind() event to fire any time something happens *within* a web part. Is this done with connection contracts? OR is there just something I need to add to the code behind (I'm i C# btw) that takes care of this? Sorry if I'm not being clear, let me know where I'm foggy.



Hi fisherman961,

If you wanted to Update or automatically Bind you r Grid without firing up any events then try to use the aspnet Ajax Timer Control..  That way  you can set an interval to update the grid based on the time being set.. More informations then you can check this

http://www.asp.net/learn/ajax-videos/video-99.aspx 


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
2/26/2008 1:33:06 PM

I so wish this would work (and technically, I suppose it does), but the timer eats up a lot of resources and ends up slowing my page down significantly.

 OK, different approach. I'll post elsewhere. Thanks!

0
fisherman961
2/27/2008 4:49:01 PM

this may actually be the best place to post...

 

Forget using web parts, what if I just want to databind all of the web controls whenever another web control is databound?

0
fisherman961
2/27/2008 4:55:24 PM
Reply:

Similar Artilces:

Cannot change web part title bar properties when web part is within an update panel
We have some web parts that are wrapped within an update panel. The entire web part zone is wrapped in the update panel, as noted in other places on this forum. The problem is, any attempts to set properties within the title bar of the web part don't work (if done programatically) within the update panel. For example, if I add a web part, and then in the OnInit() function, I do this: this.Title = "My new title"; Then when I run the program, the title bar simply says, "Untitled". Is there a way to make ths work??? For the record, his is a snippet of the HTML to show the order of the cont...

Web part Personalization and Web part custom designing
  Hi all          1. I m using a GridView control in my Web Part. In that GridView i control the columns to be displayed by generating queries in run time. In my page i have six GridView controls in six web parts. Each user can customize their GridView columns. My actual requirement is i want to get the each individual user customized details when they logged in again.How can I done this plz give me a suggestion by code.    2. I want to display my web part have a rounded corner title. how can I done this. I a...

Web parts: upcoming deadline for Snippets, update on Web Parts
Hi, quick update on Web parts, since the release date for Northern Spring Campaign is approaching fast. iOS won't be released on June 2nd, we'll try to reuse as many strings as possible (if not all of them) from the existing work that it will happen. *Snippets - 25 May* A few locales (ja, pl, ru) still have a pending request for snippets. Some of them are about iOS, so they won't be used in this campaign, but it's important to have them on file for the future. *Campaign - 2 Jun* The campaign is spread across several files with small updates. The removal of...

WEB Spell Checker does not work in Web User Control and WEB HTML Editor freezes when using AJAX Update Panel
Web Spell Checker works in program but only causes a refresh in Web User Control. The HTML Editor is frozen after the refresh. App also uses AJAX control and the Web User Control is inside an Update Panel Hi, Thank you for your post! I'm afraid that you cann't use WEB Spell Checker in updatepanel because it include some inline javascript with it, but updatepanel doesn't support very well inline javascript in it. For more information about inline javascript in updatepanel, see UpdatePanel and Rendered (Inline) Javascript It seems that the UpdatePanel essentia...

Web Parts
I work for a Digital Publishing Company. The ASP.NET portal application which must allow the project managers full customization. For instance, I have a Personal Information web page which can collect all or some of the following infomration: Salutation, Title, First name, Middle Name, Last Name, Institution, Department, Street Address, city, state, postal code, country, phone, and fax number. I have designed the portal application architecture to support multiple language by using SQL Server 2005 to return all output wording based on the user's web browses langauge settings. The porta...

Invoke Ajax OnClick from Provider Web Part to Consumer Web Part
I am attempting to manage an ajax connection by calling a button onclick method on a separate web part in order to force the partial postback on the consumer.  Web part A (Provider) invokes the method on Web Part B (Consumer) Web Part A Type t = myButton.GetType();            object[] p = new object[1];            p[0] = EventArgs.Empty;            MethodInfo m = t.GetMethod("OnClick", BindingFlags.NonPublic | ...

using web parts, databind and ajax
OK, I have two different Web User Controls (.ascx files) that have GridViews on them. They're all wrapped with Ajax update panels, so when a new row is added or an existing row is edited, etc. it's not a full postback. Great, looks awesome.Here's my issue, hopefully someone has run into this before. Let's call the Gridviews GV_A and GV_B. When I add a new record to GV_A, the database creates a new ID for the record behind the scenes. In GV_B, I have a drop down list that's populated by all of the IDs listed in GV_A. If I add a new record in GV_A, I want GV_B to da...

Using Update Panels with Web Parts
Hi, I am creating a Web Part using ASP.net AJAX Extensions 1.0 to be integrated with SharePoint 2007. I am using the Update panel control to use the AJAX features, however using update panels doesnt allow me to format the UI of the Web Part as in the location of the controls in the Web Part. Can anyone please help me out with this? Webparts do not work inside the UpdatePanel in AJAX 1.0 (see http://practicals-dot-net.blogspot.com/2007/06/workaround-web-parts-updatepanel.html). You can try this workaround: http://forums.asp.net/t/1087200.aspx -DamienVisoft, Inc - Home | Blogs ...

Web parts , Web User Control, Update Panel, Javascript
Hi guys,  Hope this time someone replies first of all, Is that possible to combine all above Asp.net and Ajax controls?      The below one is my web user control code which I am using in the webpart zone. <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>   <asp:Panel ID="EditContainer" runat="server" DefaultButton="btnSubmit" > Start Date: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> End Date:&nbsp;&nbsp;<asp:TextBox ID="TexBox2" runat="server"></asp:TextBox> <asp:Butt...

Enumerating all the web parts on a page
I have a web part that needs to examine every other web part on a given page for info. I've tried two approaches, but neither seems to be the answer I'm looking for. First, I tried getting a reference to Parent (which returns the WebPartManager) and enumerating through it's Controls (or WebParts) collection. This almost works - it gives me every web part in the same WebPartZone as my web part. But it doesn't give me all the web parts in the other zones. Example:            WebPartManager wpm = (WebPartManager)this.Pa...

Atlas and Web Parts / Web Part Framework
How is Microsoft differentiating Atlas from Web Parts and the Web Part Framework? Which is the right one to use when? Web Parts provide a rich infrastructure in ASP.NET to build composite, personalized application UI from individual components. Atlas provides a richer environment in the browser client for application UI to run more interactively. These are complementary technologies. In the future, web parts and Atlas will work together in a couple of important ways. First, the web parts infrastructure will take advantage of Atlas to provide even richer client-side intera...

Web Part moves only once with Ajax Update Panel RC1
I uset Web part with Update Panel RC1. But only once DND possible. Next time it is not available...... Can anybody have solution for this.??  Chetan SarodeSoftware Engineer,Approva Systems Pvt Ltd,Pune, India. Try to specify post back through the triggers of the asp:UpdatePanel.Here are some sample codes for your reference.<div> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> </asp:ScriptManager> <asp:UpdatePanel ID="upPortal" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional"&...

Closed Web Parts with Update Panels AJAX 1.0
I know it isn't supported, but I have only one problem with AJAX 1.0. I have an ajax timer and update button on a master page for updates for all my content sections. Everything works great till I attempt to close a webpart that has an update panel, and then I javascript errors appear telling me they can no longer find the update panels on the webparts I have already closed. I tracked it down to some ScriptManager code: Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tctl00$MainWebPartManager$gwpTaskSummary1$TaskSummary1$udpTaskSummary','tctl00$MainWebPartManager$wp71908502...

Issues with Ajax Web Part using .Net Framework 3.5
 Hi, I have deployed Silverlight Media Viewer WebPart (Silverlight 2 beta 2) on my SharePoint Web Application. Its working fine. But, On this SharePoint Web application, I also have some other AJAX web parts which are developed in VS 2005 with .Net Framework 3.0.When I modified the respective web.config for .Net Framework 3.5, All the other web parts started flickering. How can I stop these Ajax web Parts from flickering? Please help me on this… I am in really need of this.  Thanks in Advance.......

Web resources about - Using Web Parts and DataBinding across Web Parts with Ajax Update Panels. - asp.net.personalization

javascript - Databinding in angularjs - Stack Overflow
Could someone explain to me how databinding works in the AngularJS framework? I haven't found technical details on their site. It's more or less ...

Styling and DataBinding Silverlight 4.0 ListBox
... for each item in the list Interaction - what happened when users interact with the ListBox and controls – mouse over effects etc. DataBinding ...

Windows Presentation Foundation - Wikipedia, the free encyclopedia
Developed by Microsoft , the Windows Presentation Foundation (or WPF ) is a computer-software graphical subsystem for rendering user interfaces ...

Tomsondev Blog - My Company
... in Austria an across Europe, providing ... Tomsondev Blog Tom's opensource development My Company About Me Posts Announcements Databinding EMF ...

Tigraine
Daniel Hoelbling talks about programming Home Articles About me Articles Over the years I accumulated a number of (at least sometimes) useful ...

Building an Web application from the inside out; Using node.js to bootstrap a server from client JS
Over the winter holiday , Ben and I whipped together Project Appetite , an open source example that consumes the feeds from the Palm application ...

Microsoft announces Silverlight 5 beta will launch first half 2011
In a keynote presentation at the Silverlight Firestarter event this morning, Corporate Vice President in Microsoft's developer division, Scott ...

Blue Spire - Products
Caliburn.Micro A small, yet powerful framework designed for WPF, Silverlight and Windows Phone 7, Caliburn.Micro makes developing maintainable, ...

Silverlight - Blackboard
Silverlight is a development platform for creating rich media applications and business applications for the Web, desktop, and mobile devices.Microsoft ...

Latest Updates
Latest Updates - Free source code and tutorials for Software developers and Architects.; Updated: 15 Feb 2013

Resources last updated: 12/5/2015 1:42:00 AM