Doing computation of data retrieved from Microsoft SQL using c# & .net 3.5

Hi I currently have a database, that contains the columns description, and cost. On the page a combo-box that gets populated from the database (datasource id = pricesheet).

I after the user inputs the quanity, and selects the description, I want to be able to search for the description in the database and also retrieve the cost. My question is how would I do that. I already have a connection string when setting up the SqlDataSource. Can I just use the existing connection string or the existing SqlDataSouce pricesheet? If so how would I do that? Thanks in advance for your help.

 

-Nelson

0
nelsonlowe
1/27/2009 5:42:00 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
901 Views

Similar Articles

[PageSpeed] 40

Hi nelsonlowe,

Of course, you can use the SqlDataSource. Here is a sample for your requirement.

Quantity:<asp:TextBox runat="server" ID="TBquantity"></asp:TextBox>
    Description:<asp:DropDownList runat="server" ID="DDLdesc" DataTextField="Description" DataValueField="Cost" DataSourceID="SqlDataSource1" AutoPostBack="true"></asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:sql %>"
      SelectCommand="select * from [table]"></asp:SqlDataSource>
    <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2" AutoGenerateColumns="false">
        <Columns>
          <asp:TemplateField>
            <ItemTemplate>
              <asp:Label ID="LBdesc" Text='<%# Eval("Description") %>' runat="server" />
            </ItemTemplate>
          </asp:TemplateField>
          <asp:TemplateField>
            <ItemTemplate>
              <asp:Label ID="LBcost" Text='<%# Calculation(Convert.ToInt32(Eval("Cost"))) %>' runat="server" />
            </ItemTemplate>
          </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:sql %>"
      SelectCommand="select * from [table] where Description=@Description">
      <SelectParameters>
        <asp:ControlParameter ControlID="DDLdesc" DefaultValue="Sample" Name="Description" PropertyName="SelectedValue" />
      </SelectParameters>
    </asp:SqlDataSource>

protected string Calculation(int cost)
    {
        if (TBquantity.Text == "")
            return (cost * 1).ToString();
        else
            return (cost * Convert.ToInt32(TBquantity.Text)).ToString();
    }

Thanks,


Qin Dian Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Qin
1/29/2009 8:25:40 AM
Reply:

Similar Artilces:

Can we replace Microsoft .Net framework 3.5 with Microsoft .NET Compact Framework 3.5
Hi, I have installed vs2008 in C drive and removed it from there  including Microsoft .Net framework 3.5, due to space crunch, then I started installing it in D drive, in this case it did not install .Microsoft .Net framework 3.5 and now it does not show me Microsoft .Net framework 3.5 it shows .NET Compact Framework 3.5 in Add remove program list. My question is will VS2008 work fine with .NET Compact Framework 3.5. apart from it it also has .NET Framework 3.5 SP1 in the list, all what is missing is microsoft .net framework 3.5  Please let me know ...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

.Net 3.5 ADO.Net Data Service & Ajax
 Hello, I was trying to use the example in the following video and I keep getting "Server Method "Categories" failed" error. I have .Net 3.5 SP1 and VS 2008, is there any workable example out there? I also added the Entity Data Model. http://www.asp.net/learn/3.5-SP1/video-239.aspx  I really like the way how you can access data in the database using javascript. Any help on this code? thx Default.aspx     <input id="ButtonQuery" type="button" value="Perform Query" onclick="return ButtonQuery_oncli...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

How to Data Transfer From Excel to Microsoft SQL Server Data base Using .Net.
Hai All, How to Data Transfer From Excel to Microsoft SQL Server Data base Using .Net. I have one Excel Sheet in that sheet 15 Fields (attributes) and 3000 records are there. In this 3000 records i want to store this (Excel) data into  5 related tables on Sql Server Database Using .Net.   How to store Excel Sheet data into Sql Server database. Please help me as soon as possible. Thank You Very Much...Have a Good Day... With RegardsSridhar...

which is shou i use? Microsoft .NET Framework 1.1 Data Provider for Oracle and the Oracle Data Provider for .NET
Microsoft .NET Framework 1.1 Data Provider for Oracle and the Oracle Data Provider for .NETI am confused?Which is better or which one should I use?BTW, I am going to use .net 2.0 with oracle 9. Can anyone tell me what shou I use for working with oracle database?Thanks very much in advance!Justin Oracle's data provider has more functionality than Microsoft's.If your doing transaction processing you can have SAVEPOINTs, which Microsoft's data provider does not provide.Also, Oracle has PL/SQL Associative Arrays which are very powerful.Oracle also allows you to bind parameters by name and pos...

Using a REST API using "Astoria" (with .NET Framework 3.5 and VS.NET 2008 SP1)
Hello! I'm really interested in learning how to work with the new .NET Framework 3.5 and VS.NET 2008 SP1 (still beta). Here is my question: I would like to use a REST API that is not made by me. I'm talking about the REST API of Community Server 2008 (www.communityserver.org). I've got the full specification of the API. They have it well documented and ready to go. It appears to be very easy to use, but... HOW? How to connect the web services with the new .NET 3.5 properly? The full specification can be read here: http://api.communityserver.org. I've successully used...

Application created in new version of .NET (3.0 or 3.5) can use the library created in older version of .NET(i.e.-1.0 or 2.0)?
Hi All, I am using Visual Studio .NET compiler for compiling my application . We have plugins (as library) which the user can write by their own in .NET . We are building our code in Visual Studio 2005 but we have already some plug-ins which are written in previous versions of Visual Studio (i.e. 2002 and 2003). Is these plug-ins will work with the new build of the application or I need to build these plug-ins as well in Visual Studio .NET 2005. These plugins are created as library. Is their any differences between .NET 1.0, 2.0 and 3.0 because of which the old libraries (created in o...

Rendering of data using .NET 3.5
Hi. I've been trying to figure this out for a while now, but it seems it's beyond my grasp - not surprising given that I'm fairly new to .NET web development. On a site I built for someone there is a timetable. That timetable renders data from SQL query that uses three tables within a SQL 2005 DB. I'm using VSWB 2008 Express Edition.The site: www.bringingyogatoyou.com - if you hit the link you'll see the timetable on the homepage down the right hand side. The SQL query: 1 SELECT ttLocation.LOCATION, ttDayOfWeek.DAY AS Expr1, ttSessions.START_TIME, ttSessions.E...

Can I switch from .Net 3.5 to .Net 3
After finishing the website that I built in VS 2008 and has AjaxControlToolkit controls. I was informed by the network admin that the server has .Net 3 and that we can't install .Net 3.5. I tried to change the application settings from Property Page --> Build node, and then select .Net Framework 3.0 from Target Framework Dropdownlist, and then click OK BUT then I can't run my application I get error message and the     <asp:ScriptManager ID="ScriptManager1" runat="server" />   is unknown even when I try ...

.NET 3.5 SP1 & ADO.NET Entity Framework Clarification
I'm a little confused, can someone please clarify, with the recent release of .NET 3.5 SP1....  does that include an official "release" of the ADO.NET Entity Framework?  Or is the framework still in early pre-release stages?Thanks,Matt BrownMetalReview.com - Metal music community and reviewsHaulix - Easy promotional media distribution for the music industry Entity Framework is officially released and is part of SP1. Sweet times, sweet times. This is the official forum for it: http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=533&SiteID=1 The forum was no...

Using .NET 3.5 & Silverlight in VS2005?
Hi, I have been forced (by management)  to stop using VS2008 .NET 3.5.1 and revert my new projects back to VS2005.  Well the issues I have is with the Ajax Toolkit and Silverlight from .NET 3.5 I get all sorts of errors mostly saying something to the nature of Error Creating Control - ScriptManager1 "Unknown server tag 'asp.mediaplayer" - Seems to be related to Silverlight Error Creating Control - TabContainer1  This control cannot be displayed because it TagPrefix in not registered in this web form. - Seems to be related to Ajax Toolkit. Can I use ASP.NET ...

setup AP.NET membership database & web.config in .NET 3.5?
 A long time ago I setup an ASP.NET security database using aspnet_regsql.exe. I noticed this utility doesn't ship with .NET 3.5. Can anyone direct me to a writeup of how to create the security database and modify the web.config for membership? Thanks! Michael  Hello Michael, You still use the .net framework version 2 version of aspnet_regsql.exe in something like C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727As I understand it ver 3.5 is just adding new features onto the version 2 framework but mostly asp.net is just the same. Hope it helps JeremyRegardsJeremyIf ...

retrieve selected data from SQL database using vb.net
I already watch the video in the vb.net express to learn about the data binding. But the problem that i face is when i want to retrieve certain data from the database. the video just show how to fill and update. who ever know the code to retrieve the selected row from the SQL database using vb.net 2005????? thanks do u want to retrive a particular cell or a particular row from the database?what control do you want to bind the retrived value to? thanks Imran NathaniLet the game begin!!Barcode image generation made easy.Writing an ActiveX Control in C#Generating Relational Data From XML D...

Web resources about - Doing computation of data retrieved from Microsoft SQL using c# & .net 3.5 - asp.net.presentation-controls

Computation - Wikipedia, the free encyclopedia
that follows a well-defined model understood and expressed as, for example, an algorithm , or a protocol . The study of computation is paramount ...

Evolutionary computation - Wikipedia, the free encyclopedia
In computer science , evolutionary computation is a subfield of artificial intelligence (more particularly computational intelligence ) that ...

bit-player - An amateur's outlook on computation and mathematics
In a few days bit-player will celebrate its seventh birthday. (The first published post was dated January 9, 2006.) The original design for the ...

Bubble Math – Place Value Computation Tactics Educational Game for kids on the App Store on iTunes
Get Bubble Math – Place Value Computation Tactics Educational Game for kids on the App Store. See screenshots and ratings, and read customer ...

All sizes - A Beautiful Computation - Flickr - Photo Sharing!
Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to ...

Stuart Hameroff on Singularity 1 on 1: Consciousness is More than Computation! - YouTube
http://www.singularityweblog.com/stuart-hameroff-quantum-consciousness/ Dr. Stuart Hameroff is a Professor of Anesthesiology and Psychology, ...

Big data under the spotlight at Curtin Institute for Computation
Curtin University has opened the Curtin Institute for Computation (CIC) in Western Australia to focus on computation and data analytics research. ...

How to get faster fiber-optic pipes through computation
Calculation compensates for fiber imperfection, may increase data rates.

Luis von Ahn: The Pioneer of "Human Computation" - Businessweek
MacArthur Fellow Luis von Ahn's programs harness human abilities to solve large-scale, complex problems The New York Times (NYT) has published ...

Wolfram doesn’t use computation in URS dispute
A lot of brain power missed the connection. Wolfram Research, Inc. has lost a Uniform Rapid Suspension (URS) case for mathematica.guru and wolfram.ceo, ...

Resources last updated: 11/30/2015 10:33:59 PM