473,322 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

problem with adding row to datatable

Hi
In my application I try to add one row from datagrid into datatable and I
recive the following message:

Exception Details: System.ArgumentException: This row already belongs to
another table.
The part of code that realize this procedure look:
private void dg1_SelectedIndexChanged(object sender, System.EventArgs e)
{
DataSet ds1 = new DataSet();
string xmlPath;
xmlPath = Server.MapPath("")+"\\ds.xml";
ds1.ReadXml(xmlPath);
DataTable dt = new DataTable();
DataRow dr;
dr = ds1.Tables["person"].Rows[dg1.SelectedIndex];
dt.NewRow();
dt.Rows.Add(dr);
// error occur in this line dg2.DataSource=dt;
dg2.DataBind();
}
Dataset is in xml file and one of tables "person" is binded with dg1
datagrid and I clik into select column of this datagrid for run
dg1_SelectedIndexChanged
I need help
thnks
Bobo
Jul 19 '05 #1
4 11994
This is a classic asp newsgroup. While you may be lucky enough to find a
dotnet-savvy person here who can answer your question, you can eliminate the
luck factor by posting your question to an appropriate group. I suggest
microsoft.public.dotnet.framework.aspnet.

HTH,
Bob Barrows
"Bobofrut" <e-********@wp.pl> wrote in message
news:bd**********@atlantis.news.tpi.pl...
Hi
In my application I try to add one row from datagrid into datatable and I
recive the following message:

Exception Details: System.ArgumentException: This row already belongs to
another table.
The part of code that realize this procedure look:
private void dg1_SelectedIndexChanged(object sender, System.EventArgs e)
{
DataSet ds1 = new DataSet();
string xmlPath;
xmlPath = Server.MapPath("")+"\\ds.xml";
ds1.ReadXml(xmlPath);
DataTable dt = new DataTable();
DataRow dr;
dr = ds1.Tables["person"].Rows[dg1.SelectedIndex];
dt.NewRow();
dt.Rows.Add(dr);
// error occur in this line dg2.DataSource=dt;
dg2.DataBind();
}
Dataset is in xml file and one of tables "person" is binded with dg1
datagrid and I clik into select column of this datagrid for run
dg1_SelectedIndexChanged
I need help
thnks
Bobo

Jul 19 '05 #2
Bob, Ray ??
Ray, are you cutting and pasting Bob's answers?

"Ray at <%=sLocation%>" <as*@me.forit> wrote in message
news:ee**************@TK2MSFTNGP11.phx.gbl...
This is a classic asp newsgroup. While you may be lucky enough to find a
dotnet-savvy person here who can answer your question, you can eliminate the luck factor by posting your question to an appropriate group. I suggest
microsoft.public.dotnet.framework.aspnet.

HTH,
Bob Barrows
"Bobofrut" <e-********@wp.pl> wrote in message
news:bd**********@atlantis.news.tpi.pl...
Hi
In my application I try to add one row from datagrid into datatable and I recive the following message:

Exception Details: System.ArgumentException: This row already belongs to
another table.
The part of code that realize this procedure look:
private void dg1_SelectedIndexChanged(object sender, System.EventArgs e)
{
DataSet ds1 = new DataSet();
string xmlPath;
xmlPath = Server.MapPath("")+"\\ds.xml";
ds1.ReadXml(xmlPath);
DataTable dt = new DataTable();
DataRow dr;
dr = ds1.Tables["person"].Rows[dg1.SelectedIndex];
dt.NewRow();
dt.Rows.Add(dr);
// error occur in this line dg2.DataSource=dt;
dg2.DataBind();
}
Dataset is in xml file and one of tables "person" is binded with dg1
datagrid and I clik into select column of this datagrid for run
dg1_SelectedIndexChanged
I need help
thnks
Bobo


Jul 19 '05 #3
I was trying to save Bob some time. :]

Ray at work

"Tom B" <sh*****@hotmail.com> wrote in message
news:Oq**************@TK2MSFTNGP11.phx.gbl...
Bob, Ray ??
Ray, are you cutting and pasting Bob's answers?

"Ray at <%=sLocation%>" <as*@me.forit> wrote in message
news:ee**************@TK2MSFTNGP11.phx.gbl...
This is a classic asp newsgroup. While you may be lucky enough to find a
dotnet-savvy person here who can answer your question, you can eliminate the
luck factor by posting your question to an appropriate group. I suggest
microsoft.public.dotnet.framework.aspnet.

HTH,
Bob Barrows
"Bobofrut" <e-********@wp.pl> wrote in message
news:bd**********@atlantis.news.tpi.pl...
Hi
In my application I try to add one row from datagrid into datatable and I
recive the following message:

Exception Details: System.ArgumentException: This row already belongs

to another table.
The part of code that realize this procedure look:
private void dg1_SelectedIndexChanged(object sender, System.EventArgs e) {
DataSet ds1 = new DataSet();
string xmlPath;
xmlPath = Server.MapPath("")+"\\ds.xml";
ds1.ReadXml(xmlPath);
DataTable dt = new DataTable();
DataRow dr;
dr = ds1.Tables["person"].Rows[dg1.SelectedIndex];
dt.NewRow();
dt.Rows.Add(dr);
// error occur in this line dg2.DataSource=dt;
dg2.DataBind();
}
Dataset is in xml file and one of tables "person" is binded with dg1
datagrid and I clik into select column of this datagrid for run
dg1_SelectedIndexChanged
I need help
thnks
Bobo



Jul 19 '05 #4
Thanks Bob. Hope you aren't sore with me for plagiarizing you. Your reply
to the .net questions amuse me almost as much as Aaron's FAQ page.

Ray at work

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:eU**************@tk2msftngp13.phx.gbl...
More power to ya! :-)

Ray at <%=sLocation%> wrote:
I was trying to save Bob some time. :]

Ray at work

"Tom B" <sh*****@hotmail.com> wrote in message
news:Oq**************@TK2MSFTNGP11.phx.gbl...
Bob, Ray ??
Ray, are you cutting and pasting Bob's answers?

"Ray at <%=sLocation%>" <as*@me.forit> wrote in message
news:ee**************@TK2MSFTNGP11.phx.gbl...
This is a classic asp newsgroup. While you may be lucky enough to
find a dotnet-savvy person here who can answer your question, you
can eliminate the luck factor by posting your question to an
appropriate group. I suggest
microsoft.public.dotnet.framework.aspnet.

HTH,
Bob Barrows
"Bobofrut" <e-********@wp.pl> wrote in message
news:bd**********@atlantis.news.tpi.pl...
> Hi
> In my application I try to add one row from datagrid into
> datatable and I recive the following message:
>
> Exception Details: System.ArgumentException: This row already
> belongs to another table.
>
>
> The part of code that realize this procedure look:
> private void dg1_SelectedIndexChanged(object sender,
> System.EventArgs e) {
> DataSet ds1 = new DataSet();
> string xmlPath;
> xmlPath = Server.MapPath("")+"\\ds.xml";
> ds1.ReadXml(xmlPath);
> DataTable dt = new DataTable();
> DataRow dr;
> dr = ds1.Tables["person"].Rows[dg1.SelectedIndex];
> dt.NewRow();
> dt.Rows.Add(dr);
> // error occur in this line dg2.DataSource=dt;
> dg2.DataBind();
> }
> Dataset is in xml file and one of tables "person" is binded with
> dg1 datagrid and I clik into select column of this datagrid for run
> dg1_SelectedIndexChanged
> I need help
> thnks
> Bobo


Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: smita | last post by:
Hi, I have an xml file as below <root> <table id =1> <user>abc</user> <age>25</age> </table> <table id = 2> <user>xyz</user>
7
by: Joe | last post by:
Not sure what group this question is better suited for so I sent it to both. I have a DataTable which contains 1545 rows. I have a method that returns a DataTable of distinct rows based on one...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
3
by: Robin Thomas | last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental. Anyway, quite often I am pulling data from a database, but then I need to use that data to produce more data. A simple...
2
by: ven | last post by:
Hello i have a dynamic datatable in my page. I wanna to write data to textboxes and after click on button "ADD data" i want to refresh datagrid on page... Here is my code : ' Insert page code...
1
by: Daniel | last post by:
Hi, i create datatable using code and add some columns in it.. the problems happen sometimes i load the datatable for the lst time, the error happens at createing the column: the error message...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
9
by: cc | last post by:
Hi, I having created a simple WebService (in VS 2005) with just one WebMethod as follows : public DataTable GetProducts() { DataTable objDataTable = null; // code for filling up the...
4
by: Aryan | last post by:
Hi, I am having problem with DataTable.Select() method. I am using ASP.NET 2.0. I have DataSet which reads data from XML file using DataSet.ReadXML(). Now this dataset has various datatable,...
8
by: jehugaleahsa | last post by:
Hello: We wrote an entire application where we add our DataRows to our DataTables immediately. However, we have to shut off our constraints to do this. We would like to use detached DataRows to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.