By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,091 Members | 1,917 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,091 IT Pros & Developers. It's quick & easy.

problem with adding row to datatable

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.