?
Solved

refresh data in dropdownlist  asp.net

Posted on 2008-10-21
3
Medium Priority
?
1,234 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 2000 total points
ID: 22773706
Use the FindControl() method E.g.
Dim ddl as DropDownList = DirectCast(FormView1.FindControl("[Dropdownlistid]", DropDownList)
ddl.DataBind()
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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