|
the following code snippet generate classes nodes has a childe nodes "Semester"
private void FillTreeNodes()
{
SysClass sysclass = new SysClass();
DataSet ds= sysclass.GetAllSysClasss();
TreeNode node;
foreach (DataRow row in ds.Tables[0].Rows)
{
node = new TreeNode();
node.Text = row["Class"].ToString();
node.Value = row["ClassId"].ToString();
node.NavigateUrl = "UpdateClass.aspx?classId="+node.Value;
GenerateSemesters(node,int.Parse(row["ClassId"].ToString()));
tree1.Nodes.Add(node);
}
}
private void GenerateSemesters(TreeNode node,int classid)
{
Semester semester=new Semester();
DataSet ds = semester.GetAllSemesters(classid);
TreeNode childenode;
foreach (DataRow row in ds.Tables[0].Rows)
{
childenode = new TreeNode();
childenode.Text = row["SemesterName"].ToString();
childenode.Value = row["SemesterId"].ToString();
childenode.NavigateUrl = "Updatesemester.aspx?semesterId=" + childenode.Value;
node.ChildNodes.Add(childenode);
}
}
i forget to minsion that is the best way for filling treeview is recursively !
modified on Monday, March 29, 2010 4:46 AM
|
|
|
|
|
|
Hi every one.
I'm working with MS Access2007-2010.As you know MS Access is too weak to make good program with it.For some reason i'm forced to work with MS Access.But it's too limited and i can't do what ever i want like C#.
I want to know is there any way to write c# code and use it in MS Access?
And use c# components in Access?
And imagin i have access form with some textBoxs,How can make the data encrypted and save it in Access dataBase?(From Access Forms,like the thing we do in C# Forms).
Thank you.
CanI
|
|
|
|
|
As far as I am aware you are stuck with the Access variant of VBA for your programming needs.
However, you should be able to create a dll (in c# or c++) and use that in the code (You'll have to look that bit up: it has been a lot of years since I used Access).
Roya Rayane wrote: MS Access is too weak to make good program with
That's really going to depend upon the requirement. If it's for an enterprise type solution then yes, you should be looking at something more robust like ORacle or SQl Server. However, for small, departmental requirements where there are few users, it might be just fine.
me, me, me
"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven
|
|
|
|
|
You can write components in C#, exposing them through COM, which can be used in Access VBA. You cannot write C# code directly in Access and expect it to work.
|
|
|
|
|
How can i have something like this :
int i=0;
if(i>0)
List<string> Age = new List<string>();
else if(i==0)
List<int> Age = new List<int>();
string strAge = Age.ToString();
it gives this Error :
Error : The name 'Age' does not exist in the current context
Please give me a Solution.
modified on Monday, March 29, 2010 2:01 AM
|
|
|
|
|
Use like this.Age is not in if block thats why it not found.
List Age;
int i=0;
if(i>0)
Age = new List();
else if(i=0)
Age = new List();
string strAge = Age.ToString();
|
|
|
|
|
ummm ... isnt that the same as:
List Age = new List();
string strAge = Age.ToString();
because I is always going to be 0 in this case. Also if its not 0 it does the same thing as if it is 0 so ...
Brad Barnhill
|
|
|
|
|
How can i have something like this :
int i=0;
if(i>0)
List<string> Age = new List<string>();
else if(i==0)
List<int> Age = new List<int>();
string strAge = Age.ToString();
it gives this Error :
Error : The name 'Age' does not exist in the current context
Please give me a Solution.
|
|
|
|
|
You are attempting to create the List<>Age in the if statements and then working with Age outside the if statements, VS gets does not know if Age actually exists.
What if i = -1, neither of your ifs will create Age and it would be null so vs spits the dummy and makes you clean up your code. And as you are trying to make the list different formats then you are in trouble, if there is going to be characters in your Age then just use List<string> and test the values for numerics in the consuming process.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
I knew that But i want to do something like my question ?
|
|
|
|
|
As a rule, you cannot create an instance in single line if block.
so,
jojoba2011 wrote: if(i>0) List<string> Age = new List<string>();
is illegal.
Now, to be able to do this, you need to cover them in curly brackets. which means that the list you created doesn't exist outside the if block and hence the error.
|
|
|
|
|
string strAge;
int i=0;
if (i > 0)
{
List<string> Age = new List<string>();
strAge = Age.ToString();
}
else if (i == 0)
{
List<int> Age = new List<int>();
strAge = Age.ToString();
}
Check if this works.
Tej Aj,
http://opexsolution.com/forum/[^]
|
|
|
|
|
1. The above code still does not compile: you must give value strAge before the if blocks.
2. I think the OP might want something more than just the type name of the list.
|
|
|
|
|
string strAge = "";
int i = 0;
if (i > 0)
{
List<string> Age = new List<string>();
strAge = Age.ToString();
}
else if (i == 0)
{
List<int> Age = new List<int>();
strAge = Age.ToString();
}
I have checked this. It works fine. Try checking it again by initializing strAge="" at the start.
Also strAge is already declared before if block.
Tej Aj,
http://opexsolution.com/forum/[^]
|
|
|
|
|
Is there any issue if you use a List<object> for doing this?
int i=0;
List<object> Age = new List<object>();
string strAge = Age.ToString();
WWW, WCF, WWF, WPF, WFC .... WTF
|
|
|
|
|
That's kind of pointless. You've created a generic of type object which is the same as just having a none-generic List. What you are doing here is requiring that both types need to be boxed/unboxed which is an expensive operation - this is precisely the type of thing that generics were introduced to avoid.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You are correct that boxing/unboxing is an expensive operation, but in this particular scenario we can’t have a generic list declared at the top and can be used for both int and string.
WWW, WCF, WWF, WPF, WFC .... WTF
|
|
|
|
|
A hint, format it better, like this:
int i=0;
if(i > 0){
List<string> Age = new List<string>();
}
else {
if(i==0) {
List<int> Age = new List<int>();
}
}
string strAge = Age.ToString();
This way (maybe this is personal, but for me it is easier) you'll see that Age is in fact only declared within the if and else scope. Not outside.
V.
|
|
|
|
|
Do you want to use a generic list whose type depends on the value of some other variable? If so, you could use something like:
System.Collections.IList myList;
bool useInts = true;
if (useInts)
myList = new System.Collections.Generic.List<int>();
else
myList = new System.Collections.Generic.List<string>();
if (useInts)
myList.Add(7);
else
myList.Add("John Doe");
Console.WriteLine(myList[0].ToString());
It will allow data of the defined type only, i.e. when you useInts is true, a myList.Add("John Doe"); statement will throw an exception.
|
|
|
|
|
Hi all,
I am going to write an application in c# (probably with asp.net) which will take pc microphone to communicate with users over existing GSM operators.
It will make the conversation with users distributed over the country and record the conversation.
How can I proceed.
please provide me as much information as possible.
|
|
|
|
|
This is really a stupid question in this forum, take it to the design and architecture forum where you may get someone to discuss this with you.
Even there you will need to have some ideas of your own and asking for as much info as possible is just plain rude!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
hi! i want to create a popup window in my desktop application,which appear at program startup on the position above the system clock, please give some general ideas to do so.
thanks
|
|
|
|