How its working ??

S

Sukh

Hi All,

Can anyone help me to understand this.
please see the code:


private fun1(){
int count1, count2;
string strTest;
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("No");
dt.Columns.Add(dc1);
DataRow dr = dt.NewRow();
dr["No"] = "100";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["No"] = "101";
dt.Rows.Add(dr);
strTest = "Test String";
Session["MYDT"] = dt;
Session["STR"] = strTest;
count1 = ((DataTable)Session["MYDT"]).Rows.Count; //2
dt.Clear();
strTest = "";


DataRow dr1 = dt.NewRow();
dr1["No"] = "AAA";
dt.Rows.Add(dr1);
Session["DT1"] = dt;
count1 =((DataTable)Session["DT1"]).Rows.Count; //1
count2 =((DataTable)Session["MYDT"]).Rows.Count; //1


Session.RemoveAll();}

If I delete dt.clear() line it gives me both datatable MYDT with 2
rows and DT1 with one row, which is correct.
but with dt.clear() its retuning me 1 row for both table but not
behaving same with STR. why.
thanks for looking this post.
 
H

Herfried K. Wagner [MVP]

Sukh said:
Can anyone help me to understand this.
please see the code:

private fun1(){
int count1, count2;
string strTest;
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("No");
dt.Columns.Add(dc1);

.... where is the relation to the VB.NET programming language?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top