|
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
|
|
|
|
|
I'm writing a factory class that populates the objects from a database.
The id field has a public get accessor but no set accessor for obvious reasons. The object is not defined in the same project as the datafactory so I can't use internal to get to it.
InjectID is in the abstractFactoryBase class from which my databasefactory is derived.
Probably a crazy way to design an app but it's working the way i want with that last change and so far it seems very clean to use.
Russell
|
|
|
|
|
I knew there's more to it, but couldn't get the picture
Russell Jones wrote: The id field has a public get accessor but no set accessor for obvious reasons. The object is not defined in the same project as the datafactory so I can't use internal to get to it.
There is attribute that does that. InternalsVisibleToAttribute[^]. Little brutal tho.
"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
|
|
|
|
|
Wow, i don't believe such an attribute exists.
That seems wrong on so many levels,
Brutal seems a very good description
Russell
|
|
|
|
|
Hi,
I'm creating something looked like the development enviorment in Visual Studio.
I have a panel with a listbox for "Activities".
I also have a panel with properties to change those activities properties.
I'm working on the deletion of activities but i'm having problems with the listbox.
i have the following two functions
<br />
private void lbActivities_SelectedIndexChanged(object sender, EventArgs e)<br />
{<br />
if (lbActivities.Items.Count!=0)<br />
{<br />
selectedActivityName = lbActivities.SelectedItem.ToString();<br />
selectedActivityIndex = activities.FindIndex(withName);<br />
<br />
pgProperties.SelectedObject = activitiesPropertyBags[selectedActivityIndex];<br />
}<br />
}<br />
This is a event for the listbox item change.
Well, i use two global variables to keep track of the selected item name and index. I also use a list to store my activities.
(is this stupid? could i use the listbox to do the same as the list, and avoid the use of two different structures?)
And here i have the code for deletion:
<br />
if (lbActivities.Items.Count != 0)<br />
{<br />
if (selectedActivityIndex == 0) {<br />
selectedActivityIndex = (lbActivities.Items.Count - 1) - 1;<br />
lbActivities.SelectedItem = lbActivities.Items[selectedActivityIndex];<br />
}<br />
else {<br />
selectedActivityIndex = lbActivities.SelectedIndex - 1;<br />
lbActivities.SelectedItem = lbActivities.Items[selectedActivityIndex];<br />
}<br />
<br />
lbActivities.Items.Remove(selectedActivityName);<br />
activities.RemoveAt(activities.FindIndex(withName));<br />
}<br />
}<br />
The problem is that when the lbActivities.Items.Remove(selectedActivityName); is executed, the SelectedIndexChanged callback is called, and occurs an exception in the following instruction:
selectedActivityName = lbActivities.SelectedItem.ToString();
This happens even after i wrote the code above, which trys to change the selected item in order to avoid the selection of non existent item.
Any tips?
Thank you very much,
Nuno
|
|
|
|
|
you could set a bool _deletion in progress when you start doing the delete. In the selectedindex changed look for that flag and exit after changing it back to false.
The temptation with a lot of this code is to stick your list into a listbox and use it to maintain your collection. I always try not to do this as i find it leads to logic that is very hard to disentangle from presentation code. It may take more effort to maintain code this way at the start but later on you'll be glad of the separation if, for instance, you want to switch to using a treeview instead.
HTH
Russ
|
|
|
|
|
Hi,
Thx for the reply.
I managed to solve the problem setting selectedItem to null.
Thx,
Nuno
|
|
|
|