|
Michael Sync wrote: You should have an constructor in Class A.
Not necessary. The problem is you are trying to assign the property value inside the class, not inside any methods. This is not allowed.
|
|
|
|
|
Are you saying that Class A doesn't need to have the constructor? assigning the value is the second pro..
|
|
|
|
|
Michael Sync wrote: Are you saying that Class A doesn't need to have the constructor?
Yes.
|
|
|
|
|
N a v a n e e t h wrote: Yes
If there is no constructor then we can't create the object of class A. A objA = new A(); . I know there are a lot of ways to do.. but based on my example 1, I did create the object of A. but i missed to mention to have the constructor in class A and B.
|
|
|
|
|
Michael Sync wrote: If there is no constructor then we can't create the object of class A
This is not correct. You can have a class without constructor. It is optional. Try creating a class without any constructor ? It won't show any problem. I guess internally default constructor would be created automatically. If we don't want to do any initialization stuff, we can avoid writing constructor.
|
|
|
|
|
Hi Navaneeth,
Yeah. You are correct. This is the second time that I made the mistake. Sorry about that.. I didn't know that the default constructor is not a must. I always used to add the default constructor.. Thanks for correcting me..
|
|
|
|
|
Yes absolutly.
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
Vri SSK wrote: Yes absolutely.
Thanks. Vri.
|
|
|
|
|
I think Michael u r very busy but get a bit of time to respond my prob.
|
|
|
|
|
ya.. As one of my frd is going to take leave, i'm taking over the project from him.. so, i'm very busy now.. another thing is also that cp take a lit bit time to load the page.
|
|
|
|
|
in the constructor of b declare the object of a and assign the value
print()
{
A aob= new A();
n = aob.Property;
}
wasim khan
|
|
|
|
|
class B
{
A e = new A();
int n = e.Pro;
public void put()
{
Console.WriteLine(n);
}
}
<b>
I've done as given above but it's also throwing error
A field initializer cannot reference the nonstatic field, method, or property 'B.e'
<b>
|
|
|
|
|
This can be done in many ways
1st method
class A
{
protected int num = 10;
public int Pro
{
get
{
return num;
}
}
}
class B : A
{
int n = num;
public void put()
{
Console.WriteLine(n);
}
}
class Program
{
static void Main(string[] args)
{
B e = new B();
e.put();
Console.ReadLine();
}
}
2nd method
class A
{
private int num = 10;
public int Pro
{
get
{
return num;
}
}
}
class B
{
int n = 0;
public void put()
{
A a = new A();
n = a.Pro;
Console.WriteLine(n);
}
}
class Program
{
static void Main(string[] args)
{
B e = new B();
e.put();
Console.ReadLine();
}
}
Hope this helps
|
|
|
|
|
i created Microsoft Accessse database and i want to connect to it using oledb object how i can do this and the want to populate that grid from the data recived from datbase plz help me
wasim khan
|
|
|
|
|
Can you please try to google first? For example, if you want to know about how to connect the Microsoft Access database then you can type like "asp.net connect microsoft access" or similar one. The google will give a lot of results. You can read one by one. and you will get the idea about how to connect the database in ASP.NET.. then, if you got the specific problem, come back here and ask again..
|
|
|
|
|
Don't Cross post
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
http://www.getdotnetcode.com/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/AutobindDBToWinFormsApp_VB2005.htm
check the link it may help u!!
|
|
|
|
|
I had created a single bound column in gridview and i have a typeddatset with column eid and ename.
dataset is filled on page_load.
I want to bind only ename column of dataset to that bound column o grid. how to do that??
thanks in advance
Gaurav
|
|
|
|
|
Hi,
You just need to set the AutoGenerateColumns property of GridView to False. Then the GridView will display only the Bound Columns added to it.
Regards,
Ujjaval Modi
|
|
|
|
|
Hello Every body,
I want to send an encrypted mail to administrator as their is a form having some secured details of customer and want to encrypt it and send to administrator.
But I am not able to do so in asp.net2.0 with c#.
Thanks in advance.
Regards
rahul saini
|
|
|
|
|
You can google how to encrypt and decrypt the string in .NET.. Once you know how to do that then you can encrypt the body message and assign it to email object. then, send it to the one you want.
|
|
|
|
|
Hi all,
I am having a data gird which has number of records it also has a select button. what I want on clicking on any of the datagrid contents. It should show that respective value in a textbox. What event of datagrid will be suitable for it. If you know please reply me.
Thanking You
Rock Star
|
|
|
|
|
u go with grid view row data bound event ..it will retun the grid view index no u write the following code in this event in java script u get the index of the gridview row clicked then u can easly find the valus in the gid view
e.Row.Attributes.Add("onclick", "javascript:myFunction(" & e.Row.RowIndex & ");")
|
|
|
|
|
I want when user click on the select commnad in datagrid that respective data will be listed in my textbox.
Rock Star
|
|
|
|
|
u kept one hiden field and in javascript where we get the index assign it to the hideen field and take that field in the button and in the button u write textboxtext = gridview.row(hideen field).cells(hiden field).to string
|
|
|
|