Multiple Tables in SQLDataSource

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suganya
    New Member
    • Dec 2006
    • 39

    Multiple Tables in SQLDataSource

    Hi

    I have a GridView in my Page. I have to bind multiple tables into the GridView using SQLDataSource. For that I have given the coding as

    Code:
    <asp:GridView ID="Search_GridView" runat="server" Style="z-index: 100; left: 2px; position: absolute;
                top: 270px" AutoGenerateColumns="False" OnSelectedIndexChanged="Search_GridView_SelectedIndexChanged" CellPadding="20" Width="720px" AllowPaging="True" OnPageIndexChanging="Search_GridView_PageIndexChanging" DataSourceID="SqlDataSource1">
                
                 <Columns>
                     <asp:hyperlinkfield headertext="Doctors Name"
          datatextfield="DoctorsName"
          datanavigateurlfields="DoctorsName" 
          datanavigateurlformatstring="Logging.aspx?DoctorsName={0}" />
                         
     
                             <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
                             <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
                              <asp:BoundField DataField="PrimaryTitle" HeaderText="PrimaryTitle" SortExpression="PrimaryTitle" />
                     <asp:HyperLinkField Text="Fix an Appointment" HeaderText="Appointment Fixing" NavigateUrl="~/Appointment.aspx"/>
                              
                               
                             
                             
                             
                             
                        </Columns>
                
                
               
                <HeaderStyle BackColor="InactiveCaption" BorderWidth="0px" />
                <AlternatingRowStyle BackColor="Silver" />
                
                
                
                
            </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Hello_DrConnectionString3 %>"
                   SelectCommand="SELECT DoctorMaster.[FirstName]+''+DoctorMaster.[MiddleName]+''+DoctorMaster.[LastName] as DoctorsName,DrClinicDetails.[Address],DoctorMaster.[Telephone]+','+DoctorMaster.[Mobile]as Phone,PrimaryTitle.PrimaryTitle FROM [DoctorMaster],[DrClinicDetails],[PrimaryTitle],[Specialty] WHERE ((DoctorMaster.[FirstName] LIKE '%' + @FirstName + '%') OR (Specialty.[Specialty]=@Specialty) OR (DoctorMaster.[City] = @City)) AND DoctorMaster.[SPID]=Specialty.[SPID] AND PrimaryTitle.[PTID]=DoctorMaster.[PrimaryTitleID]">
                    <SelectParameters>
                        <asp:SessionParameter DefaultValue="Name" Name="FirstName" SessionField="Name" Type="String" />
                        <asp:SessionParameter DefaultValue="Location" Name="City" SessionField="Location"
                            Type="String" />
                            <asp:SessionParameter DefaultValue="Specialty" Name="Specialty" SessionField="Specialty"
                            Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
    In form load, I assigned value of session to the objects as

    Code:
    object obj;
            obj = (object)Session["Name"];
    
            object obj1;
            obj1 = (object)Session["Specialty"];
    
            object obj2;
            obj2 = (object)Session["Location"];

    but once I run GridView is not getting displayed
Working...