Advertisement

06.06.2008 at 09:10AM PDT, ID: 23464226
[x]
Attachment Details

ASP.Net Automatic update of listbox control when data is updated

Asked by mdpsolutions in .Net Editors & IDEs, Microsoft Visual Basic.Net, Microsoft Visual Studio Express

Tags: asp.net

Good morning,
I need some assistance getting my data to show up correctly on my site. Here is some background:
- I have a listbox control that is being populated when the page loads with data from a database
- I have an 'Edit List' button that makes a panel visible which contains:
      * A field to type in a new list item and an 'Add' button to add this item
      * A field that will be populated with the text of the list item selected and an 'edit' button to change the
        item
      * A 'Delete' button to delete the selected item...
- When a new item is typed into the 'Add' field and the 'Add' button is clicked nothing changes in the listbox, whereas I want the new item to be listed... but when I check the Db the new item is there

- If I refresh the page, the list still doesn't show the new item. I have to manually re-enter the URL then refresh the page before it actually shows up in the list.

- I want the new item to be added to the list as soon as the 'Add' button is pressed

I haven't tried the update or delete buttons but I'm sure once I figure out the issue with 'Add' then I can get those working too. I am sure there is something I am missing as far as how ASP.NET posts back to the server or something... any and all help is appreciated

The code from the code_behind page is attached and the .aspx code is below:
<b>BackUp List</b><br />
                                                    <asp:ListBox ID="sDetail_buList" runat="server" Width="250px" Height="200px" ></asp:ListBox>
                                                    <asp:Panel ID="updateBul_pnl" runat="server" Visible="false" Width="250px">
                                                    <center>
                                                        <table cellpadding="2px" cellspacing="0" border="0" style="font-family:Verdana; font-size:10px;color:#336699;">
                                                            <tr>
                                                                <td><asp:TextBox ID="bul_ItemToAdd" runat="server" CssClass="textboxes" style="width:160px"></asp:TextBox></td>
                                                                <td><asp:Button runat="server" ID="bul_AddItem" Text="Add" CssClass="showTicketButton" width="55px" /></td>
                                                            </tr>
                                                            <tr>
                                                                <td><asp:TextBox ID="bul_ItemToUpdate" runat="server" CssClass="textboxes" style="width:160px; color:#cccccc;">Select Item to Update</asp:TextBox></td>
                                                                <td><asp:Button runat="server" ID="bul_UpdateItem" Text="Update" CssClass="showTicketButton" width="55px" /></td>
                                                            </tr>
                                                            <tr>
                                                                <td>Select Item from the list to<br />delete then click "Delete"<br />button</td>
                                                                <td valign="top"><asp:Button runat="server" ID="bul_DeleteItems" Text="Delete" CssClass="showTicketButton" width="55px" /></td>
                                                            </tr>                                                        
                                                        </table>
                                                    </center>
                                                    </asp:Panel>Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Private Sub Page_OnLoad() Handles Me.Load
  Dim objbuListTable As New ServerDataSetTableAdapters.BUTableAdapter
   ' get backup data
                buList_query = objbuListTable.GetBUListDataByServerName(serverName)
                iCounter = sDetail_buList.Items.Count
                If iCounter = 0 Then
                    For Each item In buList_query
                        sDetail_buList.Items.Add(New ListItem(item.str_Directory, item.ItemId))
                    Next
                End If
                buList_query = Nothing
End Sub
 
Protected Sub sDetail_editButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles sDetail_editButton.Click
updateBul_pnl.Visible = True
End Sub
 
Protected Sub bul_AddItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bul_AddItem.Click
        Dim objBUTable As New ServerDataSetTableAdapters.BUTableAdapter
        objBUTable.InsertBUListItem(sDetail_sName.Text, bul_ItemToAdd.Text)
End Sub
[+][-]06.06.2008 at 11:04AM PDT, ID: 21731385

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .Net Editors & IDEs, Microsoft Visual Basic.Net, Microsoft Visual Studio Express
Tags: asp.net
Sign Up Now!
Solution Provided By: apeter
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628