Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
106 Points
91 Posts
Apr 26, 2012 03:49 AM|LINK
Sir,
WINDOWS XP/ VS2008 /SQLEXPRESS/ CODING VB
I have following code by which I want to fetch sum details in Gridview which are based on a substring of dropdownlist.
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="firmentry" DataTextField="NAME" DataValueField="NAME" Height="25px" Width="450px"> </asp:DropDownList> <asp:SqlDataSource ID="firmentry" runat="server" ConnectionString="<%$ ConnectionStrings:accountsConnectionString %>" SelectCommand="SELECT [NAME], " - " ,[CODE] FROM [FIRM] ORDER BY [NAME]"> </asp:SqlDataSource> </td> <td> </td> </tr> <tr> <td style="width: 87px"> </td> <td style="width: 577px"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataSourceID="firmsum" Height="16px" PageSize="2" Width="309px"> <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" /> <Columns> <asp:BoundField DataField="Bill" HeaderText="Bill" ReadOnly="True" SortExpression="Bill" /> <asp:BoundField DataField="Tds" HeaderText="Tds" ReadOnly="True" SortExpression="Tds" /> <asp:BoundField DataField="vat" HeaderText="vat" ReadOnly="True" SortExpression="vat" /> </Columns> <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" /> <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" /> </asp:GridView> <asp:SqlDataSource ID="firmsum" runat="server" ConnectionString="<%$ ConnectionStrings:accountsConnectionString %>" SelectCommand="SELECT SUM(BILL_AMT) AS Bill, SUM(TDS) AS Tds, SUM(VAT) AS vat FROM FIRMDT where code= @code" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="code" PropertyName="SelectedValue" /> </SelectParameters> </asp:SqlDataSource>
My problem is that I want to fetch sum which is based on the code part of dropdownlist. user will select the name but the data fetched will be on the basis of code.
pl. guide
Thanks
Neeraj Bhush...
Member
106 Points
91 Posts
Gridview or Details view based on substring of a dropdownlist
Apr 26, 2012 03:49 AM|LINK
Sir,
WINDOWS XP/ VS2008 /SQLEXPRESS/ CODING VB
I have following code by which I want to fetch sum details in Gridview which are based on a substring of dropdownlist.
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="firmentry" DataTextField="NAME" DataValueField="NAME" Height="25px" Width="450px"> </asp:DropDownList> <asp:SqlDataSource ID="firmentry" runat="server" ConnectionString="<%$ ConnectionStrings:accountsConnectionString %>" SelectCommand="SELECT [NAME], " - " ,[CODE] FROM [FIRM] ORDER BY [NAME]"> </asp:SqlDataSource> </td> <td> </td> </tr> <tr> <td style="width: 87px"> </td> <td style="width: 577px"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataSourceID="firmsum" Height="16px" PageSize="2" Width="309px"> <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" /> <Columns> <asp:BoundField DataField="Bill" HeaderText="Bill" ReadOnly="True" SortExpression="Bill" /> <asp:BoundField DataField="Tds" HeaderText="Tds" ReadOnly="True" SortExpression="Tds" /> <asp:BoundField DataField="vat" HeaderText="vat" ReadOnly="True" SortExpression="vat" /> </Columns> <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" /> <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" /> </asp:GridView> <asp:SqlDataSource ID="firmsum" runat="server" ConnectionString="<%$ ConnectionStrings:accountsConnectionString %>" SelectCommand="SELECT SUM(BILL_AMT) AS Bill, SUM(TDS) AS Tds, SUM(VAT) AS vat FROM FIRMDT where code= @code" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="code" PropertyName="SelectedValue" /> </SelectParameters> </asp:SqlDataSource>My problem is that I want to fetch sum which is based on the code part of dropdownlist. user will select the name but the data fetched will be on the basis of code.
pl. guide
Thanks