Solved

refresh data in dropdownlist  asp.net

Posted on 2008-10-21
3
1,232 Views
Last Modified: 2012-06-27
ConnectionString="<%$ ConnectionStrings:AS400ConnectionString2 %>"
        OldValuesParameterFormatString="original_{0}"
        SelectCommand="SELECT * FROM [billing_contruct]"
            ConflictDetection="CompareAllValues"
            DeleteCommand="DELETE FROM [billing_contruct] WHERE [rec_id] = @original_rec_id AND (([scheme_code] = @original_scheme_code) OR ([scheme_code] IS NULL AND @original_scheme_code IS NULL)) AND (([scheme_description] = @original_scheme_description) OR ([scheme_description] IS NULL AND @original_scheme_description IS NULL)) AND (([category] = @original_category) OR ([category] IS NULL AND @original_category IS NULL)) AND (([pricescheme] = @original_pricescheme) OR ([pricescheme] IS NULL AND @original_pricescheme IS NULL)) AND (([price] = @original_price) OR ([price] IS NULL AND @original_price IS NULL)) AND (([effective_date] = @original_effective_date) OR ([effective_date] IS NULL AND @original_effective_date IS NULL)) AND (([expired_date] = @original_expired_date) OR ([expired_date] IS NULL AND @original_expired_date IS NULL))"
            InsertCommand="INSERT INTO [billing_contruct] ([scheme_code], [scheme_description], [category], [pricescheme], [price], [effective_date], [expired_date]) VALUES (@scheme_code, @scheme_description, @category, @pricescheme, @price, @effective_date, @expired_date)"
            UpdateCommand="UPDATE [billing_contruct] SET [scheme_code] = @scheme_code, [scheme_description] = @scheme_description, [category] = @category, [pricescheme] = @pricescheme, [price] = @price, [effective_date] = @effective_date, [expired_date] = @expired_date WHERE [rec_id] = @original_rec_id AND (([scheme_code] = @original_scheme_code) OR ([scheme_code] IS NULL AND @original_scheme_code IS NULL)) AND (([scheme_description] = @original_scheme_description) OR ([scheme_description] IS NULL AND @original_scheme_description IS NULL)) AND (([category] = @original_category) OR ([category] IS NULL AND @original_category IS NULL)) AND (([pricescheme] = @original_pricescheme) OR ([pricescheme] IS NULL AND @original_pricescheme IS NULL)) AND (([price] = @original_price) OR ([price] IS NULL AND @original_price IS NULL)) AND (([effective_date] = @original_effective_date) OR ([effective_date] IS NULL AND @original_effective_date IS NULL)) AND (([expired_date] = @original_expired_date) OR ([expired_date] IS NULL AND @original_expired_date IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_rec_id" Type="Int64" />
            <asp:Parameter Name="original_scheme_code" Type="String" />
            <asp:Parameter Name="original_scheme_description" Type="String" />
            <asp:Parameter Name="original_category" Type="Int32" />
            <asp:Parameter Name="original_pricescheme" Type="Int32" />
            <asp:Parameter Name="original_price" Type="Decimal" />
            <asp:Parameter Name="original_effective_date" Type="DateTime" />
            <asp:Parameter Name="original_expired_date" Type="DateTime" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="scheme_code" Type="String" />
            <asp:Parameter Name="scheme_description" Type="String" />
            <asp:Parameter Name="category" Type="Int32" />
            <asp:Parameter Name="pricescheme" Type="Int32" />
            <asp:Parameter Name="price" Type="Decimal" />
            <asp:Parameter Name="effective_date" Type="DateTime" />
            <asp:Parameter Name="expired_date" Type="DateTime" />
            <asp:Parameter Name="original_rec_id" Type="Int64" />
            <asp:Parameter Name="original_scheme_code" Type="String" />
            <asp:Parameter Name="original_scheme_description" Type="String" />
            <asp:Parameter Name="original_category" Type="Int32" />
            <asp:Parameter Name="original_pricescheme" Type="Int32" />
            <asp:Parameter Name="original_price" Type="Decimal" />
            <asp:Parameter Name="original_effective_date" Type="DateTime" />
            <asp:Parameter Name="original_expired_date" Type="DateTime" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="scheme_code" Type="String" />
            <asp:Parameter Name="scheme_description" Type="String" />
            <asp:Parameter Name="category" Type="Int32" />
            <asp:Parameter Name="pricescheme" Type="Int32" />
            <asp:Parameter Name="price" Type="Decimal" />
            <asp:Parameter Name="effective_date" Type="DateTime" />
            <asp:Parameter Name="expired_date" Type="DateTime" />
        </InsertParameters>
        </asp:SqlDataSource>        
       
        <asp:SqlDataSource ID="SqlDataSource6" runat="server"
            ConnectionString="<%$ ConnectionStrings:AS400ConnectionString2 %>"
           
            SelectCommand="SELECT * FROM [billing_category] ORDER BY [category_descrip]"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource7" runat="server"
            ConnectionString="<%$ ConnectionStrings:AS400ConnectionString2 %>"
            SelectCommand="SELECT * FROM [BILLING_PRICE]"></asp:SqlDataSource>
   
    </div>
    <asp:FormView ID="FormView1" runat="server" AllowPaging="True"
        DataKeyNames="rec_id" DataSourceID="SqlDataSource1" Width="518px">
        <EditItemTemplate>
            rec_id:
            <asp:Label ID="rec_idLabel1" runat="server" Text='<%# Eval("rec_id") %>' />
            <br />
            scheme_code:
            <asp:TextBox ID="scheme_codeTextBox" runat="server"
                Text='<%# Bind("scheme_code") %>' />
            <br />
            scheme_description:
            <asp:TextBox ID="scheme_descriptionTextBox" runat="server"
                Text='<%# Bind("scheme_description") %>' />
            <br />
            category:
            <asp:TextBox ID="categoryTextBox" runat="server"
                Text='<%# Bind("category") %>' Visible="False" />
            <asp:DropDownList ID="DropDownList5" runat="server" AutoPostBack="True"
                DataSourceID="SqlDataSource6" DataTextField="category_descrip"
                DataValueField="category_id" SelectedValue='<%# Bind("category") %>'>
            </asp:DropDownList>
            <br />
            pricescheme:
            <asp:TextBox ID="pricescheme_idTextBox" runat="server"
                Text='<%# Bind("pricescheme") %>'
                ontextchanged="pricescheme_idTextBox_TextChanged" Visible="False" />
            <asp:DropDownList ID="DropDownList7" runat="server" AutoPostBack="True"
                DataSourceID="SqlDataSource7" DataTextField="PRICE_SCHEME_DISCRIP"
                DataValueField="PRICE_SCHEMEID"  SelectedValue='<%# Bind("pricescheme") %>'>          
            </asp:DropDownList>
           
           
            <br />
            price:
            <asp:TextBox ID="priceTextBox" runat="server" Text='<%# Bind("price") %>' />
            <br />
            effective_date:
            <asp:TextBox ID="effective_dateTextBox" runat="server"
                Text='<%# Bind("effective_date") %>' />
            <br />
            expired_date:
            <asp:TextBox ID="expired_dateTextBox" runat="server"
                Text='<%# Bind("expired_date") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
                CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server"
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <InsertItemTemplate>
            scheme code:
            <asp:TextBox ID="scheme_codeTextBox" runat="server"
                Text='<%# Bind("scheme_code") %>' />
            <br />
            scheme description:
            <asp:TextBox ID="scheme_descriptionTextBox" runat="server"
                Text='<%# Bind("scheme_description") %>' />
            <asp:TextBox ID="TextBox1" runat="server" Height="20px"
                style="margin-left: 32px; margin-bottom: 0px" Visible="False" Width="306px"></asp:TextBox>
            <br />
            category:
            <asp:TextBox ID="categoryTextBox" runat="server"
                Text='<%# Bind("category") %>' style="height: 19px; margin-top: 0px;"
                Visible="False" />
            <asp:DropDownList ID="DropDownList3" runat="server"
                DataSourceID="SqlDataSource6" DataTextField="category_descrip"
                DataValueField="category_id" SelectedValue='<%# Bind("category") %>'
                AutoPostBack="True" onselectedindexchanged="DropDownList3_SelectedIndexChanged">
            </asp:DropDownList>
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Add"
                Width="44px" Height="24px" />
            <asp:Button ID="button2" runat="server" Text="save" UseSubmitBehavior="False"
                onclick="button2_Click" style="width: 63px" Visible="False"
                Height="26px" />
            <asp:Button ID="Button3" runat="server" onclick="Button3_Click"
                style="height: 26px; width: 57px" Text="cancel" Visible="False"
                Height="22px" />
            <br />
            prices cheme:
            <asp:TextBox ID="pricescheme_idTextBox" runat="server"
                Text='<%# Bind("pricescheme") %>' style="margin-top: 0px"
                Visible="False" />
            <asp:DropDownList ID="DropDownList4" runat="server"
                DataSourceID="SqlDataSource7" DataTextField="PRICE_SCHEME_DISCRIP"
                DataValueField="PRICE_SCHEMEID" AutoPostBack="True" Height="16px"
                Width="87px">
            </asp:DropDownList>
            <br />
            price:
            <asp:TextBox ID="priceTextBox" runat="server" Text='<%# Bind("price") %>' />
            <br />
            effective_date:
            <asp:TextBox ID="effective_dateTextBox" runat="server"
                Text='<%# Bind("effective_date", "{0:d}") %>' />
            <br />
            expired_date:
            <asp:TextBox ID="expired_dateTextBox" runat="server"
                Text='<%# Bind("expired_date", "{0:d}") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
                CommandName="Insert" Text="Insert" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server"
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </InsertItemTemplate>
        <ItemTemplate>
            rec_id:
            <asp:Label ID="rec_idLabel" runat="server" Text='<%# Eval("rec_id") %>' />
            <br />
            scheme_code:
            <asp:Label ID="scheme_codeLabel" runat="server"
                Text='<%# Bind("scheme_code") %>' />
            <br />
            scheme_description:
            <asp:Label ID="scheme_descriptionLabel" runat="server"
                Text='<%# Bind("scheme_description") %>' />
            <br />
            category:
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
                DataSourceID="SqlDataSource5" DataTextField="category_descrip" SelectedValue='<%# Bind("category") %>'
                DataValueField="category_id" Width="300px" Enabled="False" style="width: 139px">
            </asp:DropDownList>
            <asp:Label ID="categoryLabel" runat="server" Text='<%# Bind("category") %>' />
            <br />
            pricescheme_id:          
            <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
                DataSourceID="SqlDataSource4" DataTextField="PRICE_SCHEME_DISCRIP" SelectedValue='<%# Bind("pricescheme") %>'
                DataValueField="PRICE_SCHEMEID" Enabled="False" style="width: 139px">
            </asp:DropDownList>
            <asp:Label ID="pricescheme_idLabel" runat="server"
                Text='<%# Bind("pricescheme") %>' Visible="False" />
            <br />
            price:
            <asp:Label ID="priceLabel" runat="server" Text='<%# Bind("price") %>' />
            <br />
            effective_date:
            <asp:Label ID="effective_dateLabel" runat="server"
                Text='<%# Bind("effective_date") %>' />
            <br />
            expired_date:
            <asp:Label ID="expired_dateLabel" runat="server"
                Text='<%# Bind("expired_date") %>' />
            <br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False"
                CommandName="Edit" Text="Edit" />
            &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
                CommandName="Delete" Text="Delete" />
            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False"
                CommandName="New" Text="New" />
            <asp:SqlDataSource ID="SqlDataSource3" runat="server"
                ConnectionString="<%$ ConnectionStrings:AS400ConnectionString2 %>"
                SelectCommand="SELECT DISTINCT * FROM [billing_category] WHERE ([category_id] = @category_id)">
                <SelectParameters>
                    <asp:ControlParameter ControlID="categoryLabel" Name="category_id"
                        PropertyName="Text" Type="Int32" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource4" runat="server"
                ConnectionString="<%$ ConnectionStrings:AS400ConnectionString2 %>"
                SelectCommand="SELECT * FROM [BILLING_PRICE]">
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource5" runat="server"
                ConnectionString="<%$ ConnectionStrings:AS400ConnectionString2 %>"
                SelectCommand="SELECT * FROM [billing_category]"></asp:SqlDataSource>
        </ItemTemplate>
    </asp:FormView>
       
    </form>
</body>
</html>
myproblem is how am i going to refresh data in dropdown combo ?
please help me...
0
Comment
Question by:neil17317
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Expert Comment

by:M3mph15
ID: 22773325
Hi,
You could Clear the items in the dropdownlist and then Rebind the dropdownlist. E.g.

DropDownList1.Items.Clear()
DropDownList1.DataBind()
0
 

Author Comment

by:neil17317
ID: 22773617
my problem is my dropdownlist is inside the inserttemplate
how would i be able reference dropwnlist
so that i would be able to rebind it.

0
 
LVL 6

Accepted Solution

by:
M3mph15 earned 500 total points
ID: 22773706
Use the FindControl() method E.g.
Dim ddl as DropDownList = DirectCast(FormView1.FindControl("[Dropdownlistid]", DropDownList)
ddl.DataBind()
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question