Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-11-2012, 12:22 AM   PM User | #1
Mehdi72
New Coder

 
Join Date: Jul 2007
Posts: 88
Thanks: 12
Thanked 0 Times in 0 Posts
Mehdi72 is an unknown quantity at this point
Question Visual Web Developer 2008 - Hot To Show Total Of Column After Running A Query?

I've connected my sql database to VWD 2008 and have added a select where query. One of the columns shows a fee. I want a small label under the column to show the total of those feels but I don't want to add a column in the database itself. How do I do this?

http://soccer-europe.com/Transfers/W...Search_001.png
Mehdi72 is offline   Reply With Quote
Old 04-11-2012, 12:36 AM   PM User | #2
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
during your post-back calculate your total and store it as a variable and populate an object with it
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Old 04-11-2012, 12:48 AM   PM User | #3
Mehdi72
New Coder

 
Join Date: Jul 2007
Posts: 88
Thanks: 12
Thanked 0 Times in 0 Posts
Mehdi72 is an unknown quantity at this point
I just started using VWD yesterday so I have no idea how to do that.
Mehdi72 is offline   Reply With Quote
Old 04-11-2012, 12:52 AM   PM User | #4
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
what is VWD?
what language are you using?

scratch that i googled it- from my understanding its visual studio light- what language are you using?
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE

Last edited by alykins; 04-11-2012 at 12:59 AM..
alykins is offline   Reply With Quote
Old 04-11-2012, 12:59 AM   PM User | #5
Mehdi72
New Coder

 
Join Date: Jul 2007
Posts: 88
Thanks: 12
Thanked 0 Times in 0 Posts
Mehdi72 is an unknown quantity at this point
Visual Web Developer 2008, similar to Visual Studio. It uses aspx. It's driven by toolbars and wizards.
Mehdi72 is offline   Reply With Quote
Old 04-11-2012, 01:34 AM   PM User | #6
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
the simple answer is bind a label to it- but since you are using toolbars and wizards i have no clue what kind of interface you have available- can you access the code behind? you need to do some calculation somewhere and then fill a label
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Old 04-11-2012, 01:48 AM   PM User | #7
Mehdi72
New Coder

 
Join Date: Jul 2007
Posts: 88
Thanks: 12
Thanked 0 Times in 0 Posts
Mehdi72 is an unknown quantity at this point
Quote:
Originally Posted by alykins View Post
the simple answer is bind a label to it- but since you are using toolbars and wizards i have no clue what kind of interface you have available- can you access the code behind? you need to do some calculation somewhere and then fill a label
Hi

Yes I can view the code. I can add a label but I don't understand how to perform a caculation on the query itself. Here's the datasource if it helps?

Code:
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:TransfersConnectionString %>" 
        SelectCommand="SELECT [Player], [Position], [Previous Club] AS Previous_Club, [Transfer Fee] AS Transfer_Fee, [New Club] AS New_Club, [Type], [League], [Window] FROM [Summer_2001_2011] WHERE ([Player] = @Player)">
        <SelectParameters>
            <asp:ControlParameter ControlID="player" Name="Player" PropertyName="Text" 
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
Mehdi72 is offline   Reply With Quote
Old 04-11-2012, 01:52 AM   PM User | #8
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
Quote:
Originally Posted by alykins View Post
what is VWD?
what language are you using?

scratch that i googled it- from my understanding its visual studio light- what language are you using?

..... what.... language.... are.... you.... using?!
asp and aspx are not languages asp is typically vbscript and aspx is typically vb or C# of the three I know vb and C# extensively (sorry can't help vbs) so again- what language are you using?
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Old 04-11-2012, 01:56 AM   PM User | #9
Mehdi72
New Coder

 
Join Date: Jul 2007
Posts: 88
Thanks: 12
Thanked 0 Times in 0 Posts
Mehdi72 is an unknown quantity at this point
Visual Basic. There's also an option to use Visual C#.
Mehdi72 is offline   Reply With Quote
Old 04-11-2012, 02:14 AM   PM User | #10
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim cnstr As String = "demo connection string"
        Dim Query As String = "select * from table"
        Dim tmptbl As New DataTable

        Dim conn As New SqlConnection(cnstr)
        Using conn
            conn.Open()
            Dim cmd As New SqlCommand(Query, conn)
            cmd.CommandType = CommandType.Text
            Using cmd
                Dim dr As SqlDataReader = cmd.ExecuteReader
                tmptbl.Load(dr)
            End Using
            conn.Close()
        End Using

        Dim number As Integer = calc(tmptbl.Rows(0)(0).ToString, tmptbl.Rows(1)(1).ToString)
        Label1.Text = number.ToString
    End Sub

    Private Function calc(ByVal s1 As String, ByVal s2 As String) As Integer
        Dim i As Integer = Integer.Parse(s1)
        Dim j As Integer = Integer.Parse(s2)
        Dim total As Integer

        'do some math function...

        Return total
    End Function
should be enough to get you started- you will need to figure out how to get you index- follow the link in my sig for the msdn class lib... also most searches with the key words of class C# or VB will hit the msdn lib as top hit

note- this is a windows form- quicker to make a sln as form, but concept is the same... attach that process to a page load or a button click or whatever
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Users who have thanked alykins for this post:
Mehdi72 (04-11-2012)
Reply

Bookmarks

Tags
sum after query

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:10 PM.


Advertisement
Log in to turn off these ads.