469,271 Members | 1,481 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

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 11821
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by smita | last post: by
2 posts views Thread by ven | last post: by
1 post views Thread by Daniel | last post: by
1 post views Thread by tangus via DotNetMonster.com | last post: by
4 posts views Thread by Aryan | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.