Last post Jul 19, 2007 10:42 PM by chitti
Jul 17, 2007 10:34 PM|chitti|LINK
I have a listbox in an updatePanel that gets populated on changing a drop-down (which is not in the panel). I need to save these values on click of a button. Is there any way to do this using AJAX using Postback methods.
Jul 18, 2007 02:37 PM|ysw|LINK
which values do you need to save?
Jul 18, 2007 04:16 PM|chitti|LINK
Jul 18, 2007 04:19 PM|ysw|LINK
Do you need to save to your DB only selected items in the ListBox?
what is the structure of your DB/table where you need to store these values?
Jul 18, 2007 05:41 PM|chitti|LINK
I need to save all the values in the listbox, sometimes it depends on user selection, it could be one or more values. In the DB each value is saved as a single record.
Jul 18, 2007 07:16 PM|ysw|LINK
Can you save these values when you populate your list box in the dropdown selectedindexchanged event handler?
Jul 18, 2007 08:54 PM|chitti|LINK
I have a form with dropdown menu, upon selection of which i have two update panels with listbox and their values populated.The user can add from one listbox to another.
When the user finished adding values to the second listbox, i need to save the values to the DB.
For example say role based security for a group. The group names are in the dropdown. Upon choosing the group, i have 2 listboxes, listbox one contains all users that do not belong to this group, and listbox2 contains existing users in this group. Now i
allow the user to add or remove users from listbox 1 to listbox 2 and vice-versa. Upon completion i have a save button and all values from listbox 2 needs to be saved into the DB. I have updatePanel for these listbox so the page does not refresh.
Jul 18, 2007 09:40 PM|ysw|LINK
if you have your listboxes in update panels, you still handle most of the events in server code. You can keep track of all changes made to listox in any ViewState based property.
If you make your Save button to trigger async postback, you can save changes collected in the ViewState based propery to the databse. So, basially you can:
Jul 19, 2007 12:16 PM|pcdanno|LINK
As an addendum to what yuriy said, you may want to check out the August 2007 edition of ASP.NET Pro. The cover story does a very good job of explaining how to use the Trigger property of the UpdatePanel. Granted I haven't tried this but according to the
author, it's just a matter of adding a <Triggers> tag under your <ContentTemplate> tag. From there it's a matter of determining what type of trigger you want to define AsyncPostBacktrigger or PostBackTrigger. Next you associate the ControlID to the trigger
and then you definie the EventName.
His code looks something like this:
<asp:UpdatePanel ID="udPanel" runat="server">
<asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
Jul 19, 2007 04:45 PM|chitti|LINK
thank you very much for the responses...since iam a newbie is there any example that you have worked on and could pass it to me..
again appreciate all your help
Jul 19, 2007 07:29 PM|ysw|LINK
How do you allow your users to add more items to ListBox? If you post small code samples, we may be able to suggest you how to add database updating.
Jul 19, 2007 08:48 PM|chitti|LINK
It might be hard to read this code, but basically this is the .aspx page
width: 575px; margin-bottom: 1em;">
<asp:Button CssClass="btn" Text="Submit" OnClick="SubmitIt" runat="server"/>
Jul 19, 2007 10:31 PM|ysw|LINK
Are LinkButton1, ... LinkButton4 used to move items between listboxes?
Jul 19, 2007 10:42 PM|chitti|LINK
yes, linkbutton 1 : add single item,
linkbutton2 : remove single item
linkbutton 3 : add all items
linkbutton 4 :remove all items