Showing posts with label populate. Show all posts
Showing posts with label populate. Show all posts

Wednesday, March 28, 2012

Dynamic Data in Accordion Control

Hi guys,

I'm trying to populate dynamic data into the AJAX Accordion control. What I want is values taken from my db and posted into the Accordion panels (perhaps 20 to 30 panels per page). I can manage the paging issue (page 1, page 2, page 3 etc.) but how do I take a value from the database, place it in the header, then pick another column from the same row and place it into content, and then move onto the next row?

Any ideas?

Hello,

I made some study,

I could add dynamically it's header and content through the code.

Anyway, it works for me. if contents are simple I think O.K.

Following test code was in the Page_Load event. (VB, but code is very simple for C# to read)

Dim acdAs AjaxControlToolkit.Accordion =Me.FindControl("Accordion2")Dim pAs New AjaxControlToolkit.AccordionPaneDim lAs New Label l.Text ="content test"Dim l2As New Label l2.Text ="header test"Dim inpAs New HtmlInputButton("image")With inp .ID ="myImage_2" .Attributes.Add("src","../images/4-0.gif")End With p.HeaderContainer.Controls.Add(l2) p.HeaderContainer.Controls.Add(inp) p.ContentContainer.Controls.Add(l) acd.Panes.Add(p)

Thanks mate.

It makes sense, but I'm ending up with an error using the exact same code that you providedTongue Tied At runtime:

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 24: Line 25:Line 26: acd.Panes.Add(p)

Any idea what seems to be going wrong here?


Okies i think I've worked this out. For some reason My.FindControl wasn't working for me so I changed the code to this instead:

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Dim pAs New AjaxControlToolkit.AccordionPaneDim hAs New Label h.Text ="header text"Dim cAs New Label c.Text ="container text" p.HeaderContainer.Controls.Add(h) p.ContentContainer.Controls.Add(c) Accordion1.Panes.Add(p) Application("prodtype") = ProductTypeList.SelectedItem.TextEnd Sub

A reference directly to the Accordion control id helped. Many thanks for the help.

Cheers!

Dynamic content paired with a popupControlextender

Hi folks,

I have implemented a popup control exteder which works great, however I have to populate the content of the popup at page load. I would like the content of the popup to be dynamically generated at the time the popup is called with a server callback, kind of a PopupControlExtender meets DynamicPopulateExtender. I guess what i'm looking for is just an indication of the complexity of this task, and perhaps a pointer in the right direction.

Cheers,

Howard

Hi,

Actually, PopupControl has this functionality built in... you can set the DynamicServicePath, DynamicServiceMethod, DynamicContextKey, and DynamicControlID properties of PopupControlExtender and it will fetch dynamic content before it's shown.

Thanks,
Ted

Saturday, March 24, 2012

DropDownList to DropDownList

I want to take the selected value of DropDownListA and based on that value do a query to the database and populate DropDownListB. For example, DropDownListA contains Entity values. If the user selects entity101 then I call stored procedure where I pass in the entity value, run a select statement and get a list of properties associated with the entity name. I want to take that list and populate DropDownListB. Easy enough to do with ASP.NET using the AutoPostBack. Would be real nice to do this with Atlas. Is it possible? If so, how?Atlas control toolkit has cascading dropdowns-please download the the controltoolkit and look at the sample application code for cascading dropdowns- that should help you,

DropDownList Progress Bar - Very Large amount of data

I was wondering how to go about simulating a quick load of a page with AJAX. It takes 10 seconds to populate a huge dropdownlist (large size required). So I have a page that is blank for 10 seconds before showing any activity. The dropdownlist is populated using a code behind procedure calling an SQL 2005 DB SP.

Is it possible to load the page then fill the dropdown list with a progress indicator. (Or just an overall page loading indicator) I'd really appreciate any ideas or examples as I'm a wee bit mentally fatigued tonight :/. Thanks in advanced!

You can use?an asp:UpdatePanel?with?an?asp:UpdateProgress?to?load?data?from?database?and?fill?in?the?asp:DropDownList.
Here?are?some?sample?codes?for?your?reference.
<asp:UpdateProgress ID="UpdateProgress1" Visible="true" DisplayAfter="1" runat="server" AssociatedUpdatePanelID="udpUpperRight">
<ProgressTemplate>
????Loading...
</ProgressTemplate>
</asp:UpdateProgress
<table width="100%">
<tr>
<td valign="top">
<asp:PlaceHolder ID="pnlUpperLeft" runat="server"></asp:PlaceHolder>
</td>
<td style="width: 8px"></td>
<td>
<asp:UpdatePanel ID="udpUpperRight" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Label ID="lblDisply" runat="server" Text="This is asp:UpdateProgress testing"></asp:Label>
<br />
<asp:Image ID="img" runat="server" ImageUrl="~/images/Amazon.gif" />
<asp:Button ID="btnUpdate" runat="server" Text="Update Progress" OnClick="btnUpdate_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table
Behind Code:
protected void btnUpdate_Click(object sender, EventArgs e)
{
????//Load data from database and fill out the asp:DropDownList
}

Wish?the?above?can?help?you.

Cool thanks Ji!

You've certainly opened up my eyes to more features of the update panel. Cheers!

I'm guessing I should substitute in a dropdown where the image is. Is there a way perform the button click coded behind at load? Either way I will experiment. Thanks for the help.

DropdownList OnSelectedIndexChanged event within ModalPopupExtender

I have aModalPopupExtender with two DropdownLists. I want to populate the second dropdownlist dynamically base on the user selection in the first dropdownlist. Once user selects values from both dropdown lists, then I want to postback the entire page.

But the OnSelectedIndexChanged event of the dropdownlist is not firing whenever the selection is changed.

Is this possible withinModalPopupExtender? Appreciate your help.

You may want AutoPostBack="true" and an UpdatePanel.