freelanceprogrammers.org Forum Index » ASP

Re: datarow...indexdoesnt change


View user's profile Post To page top
peter_brunone Posted: Tue Jan 11, 2005 9:31 pm


Joined: 11 Jan 2006

Posts: 38
Re: datarow...indexdoesnt change
DataTable dt = new DataTable();

   You`re creating a new DataTable each time.  You need to persist it somehow...
maybe put the table in cache and check to see if it exists before creating it.

Cheers,

Peter

From: "devicekid" devicekid@...

hi,
here is my problem....i want to add new rows to the
datatabe...but i wana do it on the click event of a button

code goes somethin like this:

DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dr[0]=TextBox1.Text.ToString();
dr[1]=TextBox2.Text.ToString();
dr[2]=TextBox3.Text.ToString();
dt.Rows.Add(dr);
DataGrid1.DataSource=dt;
this.DataGrid1.DataBind();

this code works fine but it adds only one new row(ie. only for the
first time when it is clicked).....hence forth when u click the
button the data same row value gets changed ratehr than adding a new
row....can someone plz help

Yahoo! Groups Links







[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
devicekid Posted: Tue Jan 11, 2005 9:35 pm


Joined: 04 Jan 2005

Posts: 6
Re: datarow...indexdoesnt change
hi,
DataTable dt = new DataTable();
along with few other statements are global*



--- Peter Brunone <peterlists@...> wrote:

---------------------------------
DataTable dt = new DataTable();

   You`re creating a new DataTable each time.  You
need to persist it somehow... maybe put the table in
cache and check to see if it exists before creating
it.

Cheers,

Peter

From: "devicekid" devicekid@...

hi,
here is my problem....i want to add new rows to the
datatabe...but i wana do it on the click event of a
button

code goes somethin like this:

DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dr[0]=TextBox1.Text.ToString();
dr[1]=TextBox2.Text.ToString();
dr[2]=TextBox3.Text.ToString();
dt.Rows.Add(dr);
DataGrid1.DataSource=dt;
this.DataGrid1.DataBind();

this code works fine but it adds only one new row(ie.
only for the
first time when it is clicked).....hence forth when u
click the
button the data same row value gets changed ratehr
than adding a new
row....can someone plz help

Yahoo! Groups Links







[Non-text portions of this message have been removed]


Yahoo! Groups Sponsor ADVERTISEMENT


---------------------------------
Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo!
Terms of Service.


________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
Reply with quote
Send private message
View user's profile Post To page top
peter_brunone Posted: Tue Jan 11, 2005 10:10 pm


Joined: 11 Jan 2006

Posts: 38
Re: datarow...indexdoesnt change
   Global in what sense?

   The problem here is that you are not keeping your old DataTable; you are
creating a new one each time and adding a new row to that new table.  You need
to keep the previous datatable and add rows to that one.

From: hitesh c <devicekid@...>
Sent: Tuesday, January 11, 2005 8:35 AM

hi,
DataTable dt = new DataTable();
along with few other statements are global*

--- Peter Brunone wrote:

---------------------------------
DataTable dt = new DataTable();

   You`re creating a new DataTable each time.  You
need to persist it somehow... maybe put the table in
cache and check to see if it exists before creating
it.

Cheers,

Peter

From: "devicekid" devicekid@...

hi,
here is my problem....i want to add new rows to the
datatabe...but i wana do it on the click event of a
button

code goes somethin like this:

DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dr[0]=TextBox1.Text.ToString();
dr[1]=TextBox2.Text.ToString();
dr[2]=TextBox3.Text.ToString();
dt.Rows.Add(dr);
DataGrid1.DataSource=dt;
this.DataGrid1.DataBind();

this code works fine but it adds only one new row(ie.
only for the
first time when it is clicked).....hence forth when u
click the
button the data same row value gets changed ratehr
than adding a new
row....can someone plz help



[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
devicekid Posted: Wed Jan 12, 2005 10:46 am


Joined: 04 Jan 2005

Posts: 6
Re: datarow...indexdoesnt change
well,

u did understand my problem...so y dont u suggest
some peice of code that works for it.....



--- Peter Brunone <peterlists@...> wrote:

---------------------------------

   Global in what sense?

   The problem here is that you are not keeping your
old DataTable; you are creating a new one each time
and adding a new row to that new table.  You need to
keep the previous datatable and add rows to that one.

From: hitesh c <devicekid@...>
Sent: Tuesday, January 11, 2005 8:35 AM

hi,
DataTable dt = new DataTable();
along with few other statements are global*

--- Peter Brunone wrote:

---------------------------------
DataTable dt = new DataTable();

   You`re creating a new DataTable each time.  You
need to persist it somehow... maybe put the table in
cache and check to see if it exists before creating
it.

Cheers,

Peter

From: "devicekid" devicekid@...

hi,
here is my problem....i want to add new rows to the
datatabe...but i wana do it on the click event of a
button

code goes somethin like this:

DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dr[0]=TextBox1.Text.ToString();
dr[1]=TextBox2.Text.ToString();
dr[2]=TextBox3.Text.ToString();
dt.Rows.Add(dr);
DataGrid1.DataSource=dt;
this.DataGrid1.DataBind();

this code works fine but it adds only one new row(ie.
only for the
first time when it is clicked).....hence forth when u
click the
button the data same row value gets changed ratehr
than adding a new
row....can someone plz help



[Non-text portions of this message have been removed]



---------------------------------
Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo!
Terms of Service.


________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help