|
You could do it like this:
<br />
decimal myValue = 39171.5338997917;<br />
text myRequestedTexy = Convert.ToDouble(myValue).ToString("E");<br />
Hope it helps.
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Hi!
i am working on a hospital data base. i have two tables Administration and knowlege base.
in Administration i have columns ID, NumberOfDoctors etc, and in KnowlegeBase i have some similar columns but ofcourse differnet data.
Administration
ID Date HospitalName NumberOfDoctors ........
71 4/6/2007 Children Hospital 378 ....
153 4/19/2007 MH 600
207 4/20/2007 Our Hospital 100
227 4/15/2007 My Hospital 30
313 4/11/2007 Hospita 150
576 4/17/2007 Health Ways 80
KnowlegeBase
ID NumberOfDoctors NumberOfBeds AvgPatientPerDoc .........
1 378 1500 20 ...........
I now want to compare and iterate through the rows of Administration.NumberOfDoctors with KnowlegeBase.NumberOfDoctors.. and i dont know how to do it.
Any help.. any ideas.. anythingg....??
(using sql server2005 and c#)
|
|
|
|
|
Hi,
I have a combobox and when i remove all the elements from it, the last element name stays in the area where we can type.
i have tried to force the removal with this code:
<br />
cbProperties.SelectedItem = null;<br />
cbProperties.SelectedValue = "";<br />
cbProperties.SelectedText = "";<br />
But its not working.
Any tips?
Thx,
Nuno
|
|
|
|
|
|
How about setting the DropDownStyle property into DropDownList. That is if you don't need to type anything to the combo box.
Amir Syafrudin
|
|
|
|
|
Perfect!
Thank you very much!
Nuno
|
|
|
|
|
Hi All,
I use repeater in my project (i.e repeater1) , but OnItemCommand event not Occurs repeater_ItemCommand
i see same which uses repeater in this project such event properly work is their are any property to be set to occurs such event
Plz help me
Regard's
Anil
|
|
|
|
|
In your source page do you have the following? (see bolded text)
<asp:Repeater runat=server ID=repeater1 OnItemCommand="repeater1_ItemCommand"></asp:Repeater>
|
|
|
|
|
i have two classes class1 class2 with same functions both are same.
now
class1 c=new class1();
class2 c1=(class1)c;
to avoid an error what i should do....
ok
byebye
thanks
|
|
|
|
|
kalyan_2416 wrote: to avoid an error what i should do....
There are many possible ways to correct the error. However, without knowing more about your classes it would be difficult to say what you need to do.
I think it is more important to find out: What is the relationship between the two classes? How they are to interact with each other? How do you expect them to behave?
Essentially: What is the bigger picture?
|
|
|
|
|
class1
{
void function()
{
}
}
class2
{
void funtion()
{
}
}
static void main()
{
class1 c=new class1()
class2 c1=(class1)c;
}
this is all i know which was asked by my friend...
bye
|
|
|
|
|
kalyan_2416 wrote: this is all i know which was asked by my friend...
Then you might want to get your friend to post here because that does not give enough information.
Your solution might involve using an interface, abstract class, virtual methods or a number of other possibilities. However, without knowing more it would be pointless to try and give an answer.
|
|
|
|
|
FOr this to work at all, class2 needs to derive from class1. It doesn't matter if the functions in both classes are the same, if they have no inheritance relationship, you simply cannot cast them.
class1
{
public void Foo();
}
class2
{
public void Foo();
}
This code does not provide classes that can be cast to each other. There is no relationship.
public class1
{
public void Foo();
}
public class2 : class1
{
}
NOW class2 is of type class1. You can do this:
class2 c = new class2();
class1 c1 = (class1)c;
Note some differences :
1 - I cannot make a class1 into a class2, it is NOT a class2. class2 IS a class1, but it is more than that ( although I have not added any methods, it's automatic ).
2 - There was no need to cast c into a class2, it IS a class2. I am not sure if I needed to cast at all, I did just to be safe.
Another thing: You should really never do this:
class2 c2 = (class2) c;
This can throw exceptions at runtime. Instead, do this:
class2 c2 = c as class2;
This will assign c2 in all instances, if the cast fails, it will assign it as null. So, you add a check for null before you continue, to see if the cast was valid.
if (c2 != null)
{
// cast was valid.
}
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi all,
I have a dataset that gets filled with data from a xml file. That dataset is bound to a datagridview, how can I filter the dataset so that the datagridview only displays the relevant information.
Thanks in advance
He who laughs last is a bit on the slow side
|
|
|
|
|
string strConnectionString, strQueryString;
strConnectionString = "Provider=SQLOLEDB;Data Source=local;" +
"Initial Catalog=Northwind;Trusted_Connection=Yes;";
strQueryString = "SELECT CustomerID, CompanyName, ContactName, " +
"Phone, City, Country FROM Customers";
OleDbDataAdapter daDataAdapter = new OleDbDataAdapter(strQueryString, strConnectionString);
DataTable tblDataTable = new DataTable();
daDataAdapter.Fill(tblDataTable);
DataRow[] foundRows = tblDataTable.Select("Country = 'USA' AND City <> San Francisco'");
foreach (DataRow row in foundRows)
MessageBox.Show(row["CustomerID"].ToString() + " - " + row["ContactName"].ToString()+" - " + row["Country"].ToString());
for more info:
http://www.c-sharpcorner.com/UploadFile/raghavnayak/DataSetsIn.NETP212032005014116AM/DataSetsIn.NETP2.aspx" target="_blank" title="New Window">^]
Gautham
|
|
|
|
|
The dataset gets filled from a xml file. So I use dataset.readXML(string filename)
He who laughs last is a bit on the slow side
|
|
|
|
|
datatable.Select("Condition")
to filter rows in a datatable in dataset
|
|
|
|
|
Thanks for the quick reply
I have a column name KEY, so I want to let the user type the KEY value in a textbox, then the grid must display all matches with that textbox value in the KEY column. How will the condition look for that?
He who laughs last is a bit on the slow side
|
|
|
|
|
string strConnectionString, strQueryString;
strConnectionString = "Provider=SQLOLEDB;Data Source=local;" +
"Initial Catalog=Northwind;Trusted_Connection=Yes;";
strQueryString = "SELECT CustomerID, CompanyName, ContactName, Phone " +
"FROM Customers";
OleDbDataAdapter daDataAdapter = new OleDbDataAdapter(strQueryString, strConnectionString);
DataTable tblDataTable = new DataTable();
daDataAdapter.Fill(tblDataTable);
tblDataTable.PrimaryKey = new DataColumn[] {tblDataTable.Columns["CustomerID"]};
DataRow row = tblDataTable.Rows.Find("BERGS");
Gautham
|
|
|
|
|
Hi Everyone;
I try data dec&enc. small length of data is success but long size of data to return error Length of the data to decrypt is invalid.
Ex.
Encrypt data : 123465
up sample is decrypting no problem
Encrypt data "sample@sample.com"
this value decrypting is return error Length of the data to decrypt is invalid;
What is the problem
Everyone thanks
|
|
|
|
|
Block decryption ciphers require that the block size be correct for the cipher to work.
File Not Found
|
|
|
|
|
I've got an abstract base class containing a guild field called _id.
I've derived some classes from my base class.
1 class has overridden the _id field and one hasn't.
My problem is that the object that doesn't override the _id field fails on the SetValue() call with Field == null so i get 'Object reference not set...'
public static void InjectID(Guid id,AbstractBase dataObject)<br />
{<br />
Type abstractBaseType = dataObject.GetType();<br />
FieldInfo Field = abstractBaseType .GetField("_id");<br />
Field.SetValue(dataObject, id);<br />
}<br />
The commented out line was my original code and the line below it was an attempted fix, but both behave in the same way.
Is there a way of getting to the fields defined in a base class?
Thanks
Russell
|
|
|
|
|
Is the _id field a public field? If not the GetField method cannot find it, since it is only looking for public fields with the given field.
To find private fields use the GetField overload that takes an additional bitmask of one or more BindingsFlags e.g.
abstractBaseType.GetField("_id", BindingFlags.NonPublic | BindingFlags.Instance);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
damn, that works. I don't understand why the one that overrides it worked fine though.
Thanks for the suggestion. All my constructors are called like that, got thrown of the scent by the object that worked.
Thanks again
Russ
|
|
|
|
|
Russell Jones wrote: Is there a way of getting to the fields defined in a base class?
base._id
I am not sure what are you doing here.
Are you using reflection because _id is private? Why not use protected virtual method/property? Is InjectID method of AbstractBaseClass?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|