Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="HospitalFinder.ascx.cs" Inherits="HospitalFinder" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <div class="row" dir="rtl">
            <div class="col-lg-6">
                <div class="form-group">
                    <label>شهر:</label>
                    <asp:DropDownList ID="DropDownList2UC" runat="server" DataSourceID="SqlDataSource2UC"
                        DataTextField="CityName" DataValueField="CityID" CssClass="form-control" TabIndex="12">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSource2UC" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                        SelectCommand="SELECT * FROM [Citys] WHERE ([StateID] = @StateID) ORDER BY [CityName]">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="DropDownList1UC" Name="StateID" PropertyName="SelectedValue"
                                Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </div>
            </div>
            <div class="col-lg-6">
                <div class="form-group">
                    <label>استان:</label>
                    <asp:DropDownList ID="DropDownList1UC" runat="server" DataSourceID="HStateSDSUC" AutoPostBack="True" CssClass="form-control" DataTextField="StateName" DataValueField="StateID" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"></asp:DropDownList>
                    <asp:SqlDataSource ID="HStateSDSUC" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                        SelectCommand="SELECT * FROM [States]"></asp:SqlDataSource>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="form-group">
                    <label>فیلتر:</label>
                    <asp:TextBox ID="TextBox1" runat="server" CssClass="form-control"></asp:TextBox>
                    <br />
                    <br />
                    <asp:Button ID="Button1" runat="server" Text="Button" CssClass="btn btn-outline btn-primary btn-lg btn-block" CausesValidation="False" OnClick="Button1_Click" />
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" CssClass="table table-striped table-bordered table-hover"
                    AutoGenerateColumns="False" DataKeyNames="HospitalID" DataSourceID="SqlDataSource3UC"
                    Width="90%" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" PageSize="30">
                    <Columns>

                        <asp:CommandField ShowSelectButton="True" />

                        <asp:BoundField DataField="HospitalID" HeaderText="کد مرکز" SortExpression="HospitalID"
                            InsertVisible="False" ReadOnly="True" />
                        <asp:BoundField DataField="Name" HeaderText="نام مرکز" SortExpression="Name" />
                        <asp:BoundField DataField="Phone" HeaderText="تلفن" SortExpression="Phone" />
                        <asp:BoundField DataField="Fax" HeaderText="فکس" SortExpression="Fax" />
                        <asp:BoundField DataField="Cell" HeaderText="موبایل" SortExpression="Cell" />
                        <asp:BoundField DataField="Address" HeaderText="آدرس" SortExpression="Address" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource3UC" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                    SelectCommand="SELECT * FROM [Hospitals] WHERE (([StateID] = @StateID) AND ([CityID] = @CityID) AND (([Name] LIKE '%' + @Name + '%') OR ([Phone] LIKE '%' + @Phone + '%') OR ([Fax] LIKE '%' + @Fax + '%') OR ([Cell] LIKE '%' + @Cell + '%') OR ([Address] LIKE '%' + @Address + '%'))) ORDER BY [Name], [HospitalID]"
                    ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [Hospitals] WHERE [HospitalID] = @original_HospitalID"
                    InsertCommand="INSERT INTO [Hospitals] ([Name], [Phone], [Fax], [Cell], [Address]) VALUES (@Name, @Phone, @Fax, @Cell, @Address)"
                    OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [Hospitals] SET [Name] = @Name, [Phone] = @Phone, [Fax] = @Fax, [Cell] = @Cell, [Address] = @Address WHERE [HospitalID] = @original_HospitalID">
                    <DeleteParameters>
                        <asp:Parameter Name="original_HospitalID" Type="Int32" />
                        <asp:Parameter Name="original_Name" Type="String" />
                        <asp:Parameter Name="original_Phone" Type="String" />
                        <asp:Parameter Name="original_Fax" Type="String" />
                        <asp:Parameter Name="original_Cell" Type="String" />
                        <asp:Parameter Name="original_Address" Type="String" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="Phone" Type="String" />
                        <asp:Parameter Name="Fax" Type="String" />
                        <asp:Parameter Name="Cell" Type="String" />
                        <asp:Parameter Name="Address" Type="String" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="HStateSDSUC" Name="StateID" PropertyName="SelectedValue"
                            Type="Int32" />
                        <asp:ControlParameter ControlID="DropDownList1UC" Name="CityID" PropertyName="SelectedValue"
                            Type="Int32" />
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%" Name="Name" PropertyName="Text"
                            Type="String" />
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%" Name="Phone" PropertyName="Text"
                            Type="String" />
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%" Name="Fax" PropertyName="Text"
                            Type="String" />
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%" Name="Cell" PropertyName="Text"
                            Type="String" />
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%" Name="Address" PropertyName="Text"
                            Type="String" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="Phone" Type="String" />
                        <asp:Parameter Name="Fax" Type="String" />
                        <asp:Parameter Name="Cell" Type="String" />
                        <asp:Parameter Name="Address" Type="String" />
                        <asp:Parameter Name="original_HospitalID" Type="Int32" />
                        <asp:Parameter Name="original_Name" Type="String" />
                        <asp:Parameter Name="original_Phone" Type="String" />
                        <asp:Parameter Name="original_Fax" Type="String" />
                        <asp:Parameter Name="original_Cell" Type="String" />
                        <asp:Parameter Name="original_Address" Type="String" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>





Server Error in '/' Application.

DataBinding: 'System.Web.UI.WebControls.SqlDataSource' does not contain a property with the name 'SelectedValue'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinding: 'System.Web.UI.WebControls.SqlDataSource' does not contain a property with the name 'SelectedValue'.

Source Error:


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:



[HttpException (0x80004005): DataBinding: 'System.Web.UI.WebControls.SqlDataSource' does not contain a property with the name 'SelectedValue'.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +9558913
System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts) +104
System.Web.UI.DataBinder.Eval(Object container, String expression) +93
System.Web.UI.WebControls.ControlParameter.Evaluate(HttpContext context, Control control) +203
System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context, Control control) +50
System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext context, Control control) +101
System.Web.UI.WebControls.SqlDataSource.LoadCompleteEventHandler(Object sender, EventArgs e) +46
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Page.OnLoadComplete(EventArgs e) +9668014
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +867




Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248





What i have to do????
Posted
Updated 6-May-15 0:51am
v2

1 solution

The problem is

SQL
<asp:ControlParameter ControlID="HStateSDSUC" Name="StateID" PropertyName="SelectedValue"
            Type="Int32" />
Replace "HStateSDSUC" with your dropdownlist "DropDownList1UC". HStateSDSUC is not dropdownlist.
 
Share this answer
 
v2
Comments
Roozbeh Amiressami 6-May-15 9:36am    
thank you so much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900