Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want exactly a page like below , but only i need to select data from two tables to display in the GridView. thx!


XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <body>
    <form runat="server">
      <p><asp:dropdownlist
          id="DropDownList1"
          runat="server"
          autopostback="True">
          <asp:listitem selected>Sales Representative</asp:listitem>
          <asp:listitem>Sales Manager</asp:listitem>
          <asp:listitem>Vice President, Sales</asp:listitem>
      </asp:dropdownlist></p>
      <asp:sqldatasource
          id="SqlDataSource1"
          runat="server"
          connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
          selectcommand="SELECT LastName FROM Employees WHERE Title = @Title">
          <selectparameters>
              <asp:controlparameter name="Title" controlid="DropDownList1" propertyname="SelectedValue"/>
          </selectparameters>
      </asp:sqldatasource>
      <p><asp:listbox
          id="ListBox1"
          runat="server"
          datasourceid="SqlDataSource1"
          datatextfield="LastName">
      </asp:listbox></p>
    </form>
  </body>
</html>
Posted
Updated 27-Sep-10 0:48am
v6
Comments
Sandeep Mewara 26-Sep-10 12:52pm    
Not clear.
Sunasara Imdadhusen 27-Sep-10 1:20am    
Please provide more clarification, what you exactly want?
anupkulkarni85 27-Sep-10 4:17am    
do binding the with the drop downlist

1 solution

(I got it what he wants to know.) You will need to create a "view" at database level or join the two tables in stored procedure and return a dataset from that. Now bind the gridview from that dataset. you will get the desired result.Also, if u r not using stored procedure then you may write a statement having join, here also, to fetch data from two table. You may google for information and syntax of joins.
 
Share this answer
 
v2
Comments
omarko_hjw 27-Sep-10 13:07pm    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.

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