All, Really need some assistance, have tried with formview,detailsview,gridview. SQL Query returning correct data just one line, I want to get the data value for bs_bond_price. ASP Code as Follows <aspetailsView ID="DetailsView1" runat="server" DataSourceID="test" Height="50px" Style="z-index: 109; left: 8px; position: absolute; top: 474px" Width="125px" DataKeyNames="bs_bond_price,bs_isin,bs_issuer_id" DataMember="DefaultView" OnDataBinding="Page_Load" OnDataBound="Page_Load" OnItemCreated="Page_Load"> </aspetailsView> C# so far Label1.Text = DetailsView1.Rows[1].Cells[2].Text; I have tried various combinations of numbers in the array fields including 0's I keep getting an out of range error. All the stuff I have seen on the web so far pertains to VB.NET or the threads are very unclear. If one of you could give me a clear concise answer and explain how it works I would really appreciate it Cheers DD
VB and C# are easily converted as they are simply formatting differences (with one or two very small exceptions such as optional variables for subs/ functions) - http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx is a free online tool to convert between the two. So you are trying to display a row of data from an SQL query and then show one element of it again in a label control outside of the control? One simple solution is to define the fields to be displayed manually and then in the bs_bond_price element have it execute a function that sets the label1 text and returns the same value back to the detailsview. So would be something like: Code behind: protected string SetLabel(string value) { Label1.Text = value; return value; } Code (C#): aspx for detailsview: <asp:Literal ID="BondPriceLT" runat="server" Text='<%# SetLabel(Eval("bs_bond_price")) %>' /> Code (ASP.Net):
Hi Thanks for coming back to me however, that wasn't what I was looking for. I have listed the process steps below, Step3 & Step4 are not a problem. I need to understand how to complete Step1 & Step2 ---------------------------------------------------------------------- Step1, Grab the value supplied by the SQL server (the actual value for bs_bond_price) Step2, Stuff the value into a variable called 'a' for example Step3, Multiply 'a' by 'b'(value inserted by the user into the equation via a textbox) Step4, Produce the total in a label ---------------------------------------------------------------------- If anybody can help it would b very much appreciated Cheers DD
Yep tried it yesterday, errors on out of array. I am a real newbie to this. Please put into context for me by thinking of exactly what I am trying to do(given in the steps above) and then put all of the code in so I can understand how it fits together. really appreciate your time cheers DD
If you are only wanting to do a sum with it why on earth are you using a data control? Write the SQL and execute it to get the value and then do the maths with it. protected void CalculateValue(int B, int ProductID) { SqlConnection sqlconn = new SqlConnection("Your connection String"); string sqlQuery = "Select bs_bond_price From Tablename Where Something=@BondID"; SqlCommand sqlcomm = new SqlCommand(sqlQuery, sqlconn); // set parameters SqlParameter param = new SqlParameter("BondID", SqlDbType.Int); param.Value = ProductID; sqlcomm.Parameters.Add(param); sqlconn.Open(); double Price = sqlcomm.ExecuteScalar; sqlconn.Close(); sqlcomm.Dispose(); // calculate the value and add to label Label1.Text = "$" + (Price * B); } Code (C#):
hi i'm doing a mini project for my education. topic is desktop recorder... we capture our desktop scren as a video file this s the concept and it contain video convertor and audio converter.... bt i dont know how to create problem statement and usecase specification... plz rly me