Solved

refresh data in dropdownlist  asp.net

Posted on 2008-10-21
3
1,217 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
  • 2
3 Comments
 
LVL 6

Expert Comment

by:M3mph15
Comment Utility
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
Comment Utility
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
Comment Utility
Use the FindControl() method E.g.
Dim ddl as DropDownList = DirectCast(FormView1.FindControl("[Dropdownlistid]", DropDownList)
ddl.DataBind()
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now