|
just another asp page in the window
modified on Wednesday, July 8, 2009 9:30 AM
|
|
|
|
|
What you need is this[^]
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Yees !
I found some very good way.
and thanks for the search link
|
|
|
|
|
Hi friends,
Its very silly problem. But still it scares me.
int _Totalcnt = 62;
int _Namecnt = 31;
decimal Pctmatch = Convert.ToDecimal((_Namecnt / _Totalcnt) * 100);
I am getting value for Pctmatch as '0'. why it showing wrong. How can i get exact decimal value there?
G. Satish
|
|
|
|
|
Convert _Namecnt and _Totalcnt to decimals rather than the result of the calculation, i.e.
decimal Pctmatch = (Convert.ToDecimal(_Namecnt) / Convert.ToDecimal(_Totalcnt)) * 100;
|
|
|
|
|
|
Do not spam
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Shivass wrote: www.spiritssoft.com
Please Don't SPAM. This is second time you are doing the same thing.
|
|
|
|
|
you are a retard
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
ya, perfect. Its working now. But how to take precesion here.
i am getting value for Pctmatch = 76.876789989999
how can i get only 2 values after decimal?
G. Satish
|
|
|
|
|
ya, i got the answer. By converting to string as
Pctmatch.ToString("N2");
G. Satish
|
|
|
|
|
int _Totalcnt = 62;
int _Namecnt = 31;
decimal Pctmatch = Convert.ToDecimal((Convert.ToDecimal(_Namecnt) / Convert.ToDecimal(_Totalcnt)) * 100);
|
|
|
|
|
Use Decimal directly instead of making your _Totalcnt and _Namecnt as int why taking up memory by converting them to decimal later when you can mark them decimal in first place.
|
|
|
|
|
I can't believe you got this many replies and not the right answer, or at least, not a proper explanation ( that I could see ).
decimal PctMatch = _Namecnt/(Decimal)_Totalcnt * 100
If you divide by a decimal, you will get a decimal answer. If you divide by an int, it gets rounded and you get an int, which is THEN converted to decimal, but the decimal part has already been discarded.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thank you christian for your detailed explaination.
G. Satish
|
|
|
|
|
|
|
Do not spam
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
|
|
kishorgh wrote: wht SPAM
That was not for you !
Some one Spamming in this site and we have marked him.
|
|
|
|
|
Hiiiii......i m adding n number of text boxes dynamically in a panel. but when i m going to save those values. it gives me error. My code and error is :
Dim id As Integer = Request.QueryString("ui")
Dim cmd2 As String = ("Select Specification from DefineSpecification where CategoryID=" + ID.ToString())
Dim rdr2 As IDataReader = db.ExecuteReader(CommandType.Text, cmd2)
Dim conn As New SqlConnection
Dim cmd As New SqlCommand("Select Count(*) from DefineSpecification Where CategoryID=" + ID.ToString(), conn)
conn.ConnectionString = ConfigurationManager.ConnectionStrings("See2Buy").ConnectionString
conn.Open()
Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar())
While rdr2.Read
Dim lbl = New Label()
lbl.Width = "140"
lbl.Text = rdr2.Item("Specification")
Panel4.Controls.Add(lbl)
For counter2 As Integer = 0 To count
Dim txt = New TextBox()
txt.Width = "140"
txt.ID = "TextBoxID" + counter2.ToString
Panel4.Controls.Add(txt)
Dim txt1 As TextBox = CType(Panel4.FindControl("TextBoxID" + counter2.ToString()), TextBox)
Dim txt2 = CStr(txt1.Text)
Dim cmd3 As String = "Insert into Specification(SpecificationHeading,SpecificationDescription)Values('" + lbl.Text + "','" + txt2 + "')"
Dim dbcmd As DbCommand = db.GetSqlStringCommand(cmd3)
db.ExecuteNonQuery(dbcmd)
Next
End While
Error is: Multiple controls with the same ID 'TextBoxID0' were found. FindControl requires that controls have unique IDs.
pleas guide me
|
|
|
|
|
in which line are you getting this error....
|
|
|
|
|
in this line
Dim txt1 As TextBox = CType(Panel4.FindControl("TextBoxID" + counter2.ToString()), TextBox)
|
|
|
|
|
hi
this error is quite obvious because when datareader read second row from database counter2 in your for loop will again have same value. So, declare one counter before while loop and increament that counter in for loop.this will solve your problem
himanshu
|
|
|
|