Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi

I have a Dropdownlist,Detailview,GridView in a webpage.
In Dropdownlist i am displaying all invoice number.
Gridview has to display itemdetails related to Dropdownlist selected invoice number.
(i have done gridview using foreignkey-- invoicenumber is foreign key)
Detailview has to display the company details related to Dropdownlist selected invoice number.
i am not able to do this pls help
Dropdownlist is displaying the invoiceno it is from Item Table
detailsview fields are from Customerdetails table
foreignkey for this two control is CusId.

could you please help

Thanks
Posted
Comments
Wonde Tadesse 3-Dec-11 13:30pm    
What did you attempt so far?
[no name] 3-Dec-11 20:24pm    
Share us your code
Lancy.net 3-Dec-11 20:56pm    
Hi thanks for your reply
i used connection string pls see the code below


1 solution

Hi I tried the same by using cs code also
since this is my first project not able to understand this.
please help

Dropdownlist

 <asp:dropdownlist id="doddl" datasourceid="sds1" runat="server" autopostback="True" appenddatabounditems="True" xmlns:asp="#unknown">
                        DataTextField="DoNumber" DataValueField="DoNumber" Width="250px" OnSelectedIndexChanged="doddl_SelectedIndexChanged">
                    
                     
                
                <td align="right"><asp:sqldatasource id="sds1" runat="server" xmlns:asp="#unknown">
                        ConnectionString="<%$ ConnectionStrings:InvoiceConnectionString %>" 
                        SelectCommand="SELECT [DoNumber] FROM [ItemParent]">                    
                    

</td>


Detail view
 <asp:detailsview id="DetailsView1" datasourceid="sds2" runat="server" height="50px" width="492px" autogeneraterows="False" xmlns:asp="#unknown">
                        BackColor="White" GridLines="None" Visible="False" BorderColor="#336666" BorderStyle="Solid"
                        BorderWidth="1px" CellPadding="4">
                        <footerstyle backcolor="#FFFFCC" forecolor="#330099" />
                        <rowstyle backcolor="White" forecolor="#330099" />
                        <fields>
                            <asp:boundfield datafield="CompName" headertext="CompName">
                                SortExpression="CompName">
                            
                            <asp:boundfield datafield="CompAdd" headertext="CompAdd">
                                SortExpression="CompAdd" />
                            <asp:boundfield datafield="Tel" headertext="Tel" sortexpression="Tel" />
                            <asp:boundfield datafield="Fax" headertext="Fax" sortexpression="Fax" />
                            <asp:boundfield datafield="ContPerson" headertext="ContPerson">
                                SortExpression="ContPerson" />
                            <asp:boundfield datafield="SalesPerson" headertext="SalesPerson">
                                SortExpression="SalesPerson" />
                        </fields>
                        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
                        <editrowstyle backcolor="#FFCC66" font-bold="True" forecolor="#663399" />
                    
                    
                                   
            
            <tr>
            <td>
            <asp:sqldatasource id="sds2" runat="server" xmlns:asp="#unknown">
                    ConnectionString="<%$ ConnectionStrings:InvoiceConnectionString %>" 
                    
                    SelectCommand="SELECT CompName, CompAdd, Tel, Fax, ContPerson, SalesPerson FROM CustomerDetails WHERE (CusId = @CusId)">
                <SelectParameters>
                    <asp:sessionparameter name="CusId" sessionfield="CusId">
                        Type="String" />
                </SelectParameters>
</td></tr>


Grid view

XML
<asp:GridView ID="PrintGv" DataSourceID="sds3" runat="server" BorderWidth="1px" GridLines="None" AutoGenerateColumns="False"
                        CellPadding="4" ForeColor="#333333" Width="849px" BorderColor="#336666"
                        BorderStyle="Solid" Visible="False">
                        <Columns>
                            <asp:BoundField DataField="ItemNo" HeaderText="ItemNo" SortExpression="ItemNo">
                                <FooterStyle HorizontalAlign="Center" />
                                <HeaderStyle HorizontalAlign="Left" Width="20px" VerticalAlign="Top" BackColor="#FF99FF"
                                    BorderStyle="Solid" BorderWidth="1px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description">
                                <HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" BackColor="#FF99FF" BorderStyle="Solid"
                                    BorderWidth="1px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Qty" HeaderText="Qty" SortExpression="Qty">
                                <HeaderStyle HorizontalAlign="Left" Width="10px" VerticalAlign="Top" BackColor="#FF99FF"
                                    BorderStyle="Solid" BorderWidth="1px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                        </Columns>
                    </asp:GridView>
                    <asp:SqlDataSource ID="sds3" runat="server"
                        ConnectionString="<%$ ConnectionStrings:InvoiceConnectionString %>"
                        SelectCommand="SELECT [ItemNo], [Description], [Qty] FROM [Items] WHERE ([DoNumber] = @DoNumber)">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="doddl" DefaultValue="2011SCL001-Do"
                                Name="DoNumber" PropertyName="SelectedValue" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>




 
Share this answer
 
v2

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