Need Help Please!

T

toytoto

ok here's the code and bellow i explain the problem

// Create new data view
DataView BottomDataView = new DataView();

// Give dataview the datatable
BottomDataView.Table = myBottomDT;

DataTable myNewBottomDT = new DataTable("myNewBottomDT1");
DataRow myNewBottomDR;

#region Table Columns

// Define the columns of the table.
for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "id_futures":
myNewBottomDT.Columns.Add("Futures");
break;

case "id_planner":
myNewBottomDT.Columns.Add("Responsible");
break;

case "cd_commodity":
myNewBottomDT.Columns.Add("Commodity<BR>Service");
break;

case "tx_desc":
myNewBottomDT.Columns.Add("Description");
break;

case "qy_leadtime":
myNewBottomDT.Columns.Add("Lead Time");
break;

case "dt_planning_def":
myNewBottomDT.Columns.Add("Need Date");
break;

case "fl_memo":
myNewBottomDT.Columns.Add("Memo Only");
break;

case "qy_hrs_est":
myNewBottomDT.Columns.Add("Man Hrs Est");
break;

case "qy_hrs_act":
myNewBottomDT.Columns.Add("Man Hrs Act");
break;

case "cd_cmmt":
myNewBottomDT.Columns.Add("Type");
break;

case "id_cmmt":
myNewBottomDT.Columns.Add("Document #");
break;

case "id_vendor_no":
myNewBottomDT.Columns.Add("Vendor");
break;

case "id_po":
myNewBottomDT.Columns.Add("PO #");
break;

default:
myNewBottomDT.Columns.Add(BottomDataView.Table.Columns.ColumnName.ToString());
break;
}

}

myNewBottomDT.Columns.Add("Remove");

#endregion

#region Table Rows

foreach (DataRowView myDRV in BottomDataView)
{
myNewBottomDR = myNewBottomDT.NewRow();

for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "fl_memo":
if ( myDRV.ToString() == "1" )
{
myNewBottomDR = "Yes";
}
else
{
myNewBottomDR = "No";
}
break;

default:
myNewBottomDR = myDRV;
break;
}

}

myNewBottomDT.Rows.Add(myNewBottomDR);
}

#endregion


int temp = myNewBottomDT.Rows.Count;
int nextFutureId = Convert.ToInt32(
myNewBottomDT.Rows[temp-1]["Futures"].ToString() ) + 1 ;


//there is a problem here not sure y
myNewBottomDR = myNewBottomDT.NewRow();
myNewBottomDT.Rows.Add(myNewBottomDR);


DataView myNewBottomDV = new DataView(myNewBottomDT);
DGPlanningStatusBottom.DataSource = myNewBottomDV;
DGPlanningStatusBottom.DataBind();


if i DON'T include the blank row all postback's are working fine all
event's are triggered, but when i had the blank row before binding the
DT/DV to the datagrid i receive the following error and NO EVENT's are
triggered at all
 
T

toytoto

is there any body out there that could help me on this just lost like
over a week trying to make this work realy going crazy with this


ok here's the code and bellow i explain the problem

// Create new data view
DataView BottomDataView = new DataView();

// Give dataview the datatable
BottomDataView.Table = myBottomDT;

DataTable myNewBottomDT = new DataTable("myNewBottomDT1");
DataRow myNewBottomDR;

#region Table Columns

// Define the columns of the table.
for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "id_futures":
myNewBottomDT.Columns.Add("Futures");
break;

case "id_planner":
myNewBottomDT.Columns.Add("Responsible");
break;

case "cd_commodity":
myNewBottomDT.Columns.Add("Commodity<BR>Service");
break;

case "tx_desc":
myNewBottomDT.Columns.Add("Description");
break;

case "qy_leadtime":
myNewBottomDT.Columns.Add("Lead Time");
break;

case "dt_planning_def":
myNewBottomDT.Columns.Add("Need Date");
break;

case "fl_memo":
myNewBottomDT.Columns.Add("Memo Only");
break;

case "qy_hrs_est":
myNewBottomDT.Columns.Add("Man Hrs Est");
break;

case "qy_hrs_act":
myNewBottomDT.Columns.Add("Man Hrs Act");
break;

case "cd_cmmt":
myNewBottomDT.Columns.Add("Type");
break;

case "id_cmmt":
myNewBottomDT.Columns.Add("Document #");
break;

case "id_vendor_no":
myNewBottomDT.Columns.Add("Vendor");
break;

case "id_po":
myNewBottomDT.Columns.Add("PO #");
break;

default:
myNewBottomDT.Columns.Add(BottomDataView.Table.Columns.ColumnName.ToString());
break;
}

}

myNewBottomDT.Columns.Add("Remove");

#endregion

#region Table Rows

foreach (DataRowView myDRV in BottomDataView)
{
myNewBottomDR = myNewBottomDT.NewRow();

for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "fl_memo":
if ( myDRV.ToString() == "1" )
{
myNewBottomDR = "Yes";
}
else
{
myNewBottomDR = "No";
}
break;

default:
myNewBottomDR = myDRV;
break;
}

}

myNewBottomDT.Rows.Add(myNewBottomDR);
}

#endregion


int temp = myNewBottomDT.Rows.Count;
int nextFutureId = Convert.ToInt32(
myNewBottomDT.Rows[temp-1]["Futures"].ToString() ) + 1 ;


//there is a problem here not sure y
myNewBottomDR = myNewBottomDT.NewRow();
myNewBottomDT.Rows.Add(myNewBottomDR);


DataView myNewBottomDV = new DataView(myNewBottomDT);
DGPlanningStatusBottom.DataSource = myNewBottomDV;
DGPlanningStatusBottom.DataBind();


if i DON'T include the blank row all postback's are working fine all
event's are triggered, but when i had the blank row before binding the
DT/DV to the datagrid i receive the following error "action cancelled" and NO EVENT's are
triggered at all
 
K

Ken Cox [Microsoft MVP]

Is there code missing from your sample? It is hard to analyze when there's
no reference for myBottomDT:

// Give dataview the datatable
BottomDataView.Table = myBottomDT;

Ken

toytoto said:
ok here's the code and bellow i explain the problem

// Create new data view
DataView BottomDataView = new DataView();

// Give dataview the datatable
BottomDataView.Table = myBottomDT;

DataTable myNewBottomDT = new DataTable("myNewBottomDT1");
DataRow myNewBottomDR;

#region Table Columns

// Define the columns of the table.
for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "id_futures":
myNewBottomDT.Columns.Add("Futures");
break;

case "id_planner":
myNewBottomDT.Columns.Add("Responsible");
break;

case "cd_commodity":
myNewBottomDT.Columns.Add("Commodity<BR>Service");
break;

case "tx_desc":
myNewBottomDT.Columns.Add("Description");
break;

case "qy_leadtime":
myNewBottomDT.Columns.Add("Lead Time");
break;

case "dt_planning_def":
myNewBottomDT.Columns.Add("Need Date");
break;

case "fl_memo":
myNewBottomDT.Columns.Add("Memo Only");
break;

case "qy_hrs_est":
myNewBottomDT.Columns.Add("Man Hrs Est");
break;

case "qy_hrs_act":
myNewBottomDT.Columns.Add("Man Hrs Act");
break;

case "cd_cmmt":
myNewBottomDT.Columns.Add("Type");
break;

case "id_cmmt":
myNewBottomDT.Columns.Add("Document #");
break;

case "id_vendor_no":
myNewBottomDT.Columns.Add("Vendor");
break;

case "id_po":
myNewBottomDT.Columns.Add("PO #");
break;

default:
myNewBottomDT.Columns.Add(BottomDataView.Table.Columns.ColumnName.ToString());
break;
}

}

myNewBottomDT.Columns.Add("Remove");

#endregion

#region Table Rows

foreach (DataRowView myDRV in BottomDataView)
{
myNewBottomDR = myNewBottomDT.NewRow();

for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "fl_memo":
if ( myDRV.ToString() == "1" )
{
myNewBottomDR = "Yes";
}
else
{
myNewBottomDR = "No";
}
break;

default:
myNewBottomDR = myDRV;
break;
}

}

myNewBottomDT.Rows.Add(myNewBottomDR);
}

#endregion


int temp = myNewBottomDT.Rows.Count;
int nextFutureId = Convert.ToInt32(
myNewBottomDT.Rows[temp-1]["Futures"].ToString() ) + 1 ;


//there is a problem here not sure y
myNewBottomDR = myNewBottomDT.NewRow();
myNewBottomDT.Rows.Add(myNewBottomDR);


DataView myNewBottomDV = new DataView(myNewBottomDT);
DGPlanningStatusBottom.DataSource = myNewBottomDV;
DGPlanningStatusBottom.DataBind();


if i DON'T include the blank row all postback's are working fine all
event's are triggered, but when i had the blank row before binding the
DT/DV to the datagrid i receive the following error and NO EVENT's are
triggered at all
 
A

Alvin Bruney [MVP]

you have at least 3 data tables when u only want two. for instance, why do
you need this line:
DataView myNewBottomDV = new DataView(myNewBottomDT);
DGPlanningStatusBottom.DataSource = myNewBottomDV;
you can bind the table without creating a dataview

default:
myNewBottomDR = myDRV;
break;

this is problematic because you are setting a cross reference. you should be
using
myNewBottomDR = myDRV.ToString() if you intend to copy values. this
might be what is causing your error.

it's easier if you just copy the table schema that looping thru and manually
building a datatable by the way.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
toytoto said:
is there any body out there that could help me on this just lost like
over a week trying to make this work realy going crazy with this


(e-mail address removed) (toytoto) wrote in message
ok here's the code and bellow i explain the problem

// Create new data view
DataView BottomDataView = new DataView();

// Give dataview the datatable
BottomDataView.Table = myBottomDT;

DataTable myNewBottomDT = new DataTable("myNewBottomDT1");
DataRow myNewBottomDR;

#region Table Columns

// Define the columns of the table.
for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "id_futures":
myNewBottomDT.Columns.Add("Futures");
break;

case "id_planner":
myNewBottomDT.Columns.Add("Responsible");
break;

case "cd_commodity":
myNewBottomDT.Columns.Add("Commodity<BR>Service");
break;

case "tx_desc":
myNewBottomDT.Columns.Add("Description");
break;

case "qy_leadtime":
myNewBottomDT.Columns.Add("Lead Time");
break;

case "dt_planning_def":
myNewBottomDT.Columns.Add("Need Date");
break;

case "fl_memo":
myNewBottomDT.Columns.Add("Memo Only");
break;

case "qy_hrs_est":
myNewBottomDT.Columns.Add("Man Hrs Est");
break;

case "qy_hrs_act":
myNewBottomDT.Columns.Add("Man Hrs Act");
break;

case "cd_cmmt":
myNewBottomDT.Columns.Add("Type");
break;

case "id_cmmt":
myNewBottomDT.Columns.Add("Document #");
break;

case "id_vendor_no":
myNewBottomDT.Columns.Add("Vendor");
break;

case "id_po":
myNewBottomDT.Columns.Add("PO #");
break;

default:
myNewBottomDT.Columns.Add(BottomDataView.Table.Columns.ColumnName.ToString());
break;
}

}

myNewBottomDT.Columns.Add("Remove");

#endregion

#region Table Rows

foreach (DataRowView myDRV in BottomDataView)
{
myNewBottomDR = myNewBottomDT.NewRow();

for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "fl_memo":
if ( myDRV.ToString() == "1" )
{
myNewBottomDR = "Yes";
}
else
{
myNewBottomDR = "No";
}
break;

default:
myNewBottomDR = myDRV;
break;
}

}

myNewBottomDT.Rows.Add(myNewBottomDR);
}

#endregion


int temp = myNewBottomDT.Rows.Count;
int nextFutureId = Convert.ToInt32(
myNewBottomDT.Rows[temp-1]["Futures"].ToString() ) + 1 ;


//there is a problem here not sure y
myNewBottomDR = myNewBottomDT.NewRow();
myNewBottomDT.Rows.Add(myNewBottomDR);


DataView myNewBottomDV = new DataView(myNewBottomDT);
DGPlanningStatusBottom.DataSource = myNewBottomDV;
DGPlanningStatusBottom.DataBind();


if i DON'T include the blank row all postback's are working fine all
event's are triggered, but when i had the blank row before binding the
DT/DV to the datagrid i receive the following error "action cancelled"
and NO EVENT's are
triggered at all
 
T

toytoto

Alvin, Ken, Sorry for the confusion and useless code in the previous
message, been doing so manythings to try to make this work it's not
even funny... anyway here's the problem and new clean code.

if i DON'T include the blank row in the datatable and bind this
datatable to an editable datagrid with a few checkbox's, dropdown's,
textbox's on it etc. When i make changes to any values eg: "select
different values in one of the dropdown's" then the postback occurs
and all proper events a triggered and working fine.

now if i include the blank row in the datatable and bind this
datatable to the same editable datagrid When i make changes to any
values eg: "select different values in one of the dropdown's" then the
postback DOESN'T occur anymore and NO events are triggered and the
page returns "Action Cancelled" page. I've tried a million different
things without success placed tonnes of bookmarks in the page and none
of them receive focus when i added this blank row in the datatable.

please feel free to email directly if additional "info" or "code"
needed

here is the entire method as i use it

private void FillBottomPlanningStatusTab(DataTable myBottomDT)
{
DataView BottomDataView = new DataView();

//myBottomDT IS THE DATATABLE RECEIVED WHEN THIS METHOD IS CALLED
BottomDataView.Table = myBottomDT;

DataTable myNewBottomDT = new DataTable("myNewBottomDT1");
DataRow myNewBottomDR;

#region Table Columns

// RENAMES THE NEEDED COLUMNS FROM RECEIVED DATATABLE
for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "id_futures":
myNewBottomDT.Columns.Add("Futures");
break;

case "id_planner":
myNewBottomDT.Columns.Add("Responsible");
break;

case "cd_commodity":
myNewBottomDT.Columns.Add("Commodity<BR>Service");
break;

case "tx_desc":
myNewBottomDT.Columns.Add("Description");
break;

case "qy_leadtime":
myNewBottomDT.Columns.Add("Lead Time");
break;

case "dt_planning_def":
myNewBottomDT.Columns.Add("Need Date");
break;

case "fl_memo":
myNewBottomDT.Columns.Add("Memo Only");
break;

case "qy_hrs_est":
myNewBottomDT.Columns.Add("Man Hrs Est");
break;

case "qy_hrs_act":
myNewBottomDT.Columns.Add("Man Hrs Act");
break;

case "cd_cmmt":
myNewBottomDT.Columns.Add("Type");
break;

case "id_cmmt":
myNewBottomDT.Columns.Add("Document #");
break;

case "id_vendor_no":
myNewBottomDT.Columns.Add("Vendor");
break;

case "id_po":
myNewBottomDT.Columns.Add("PO #");
break;

default:
myNewBottomDT.Columns.Add(BottomDataView.Table.Columns.ColumnName.ToString());
break;
}

}

myNewBottomDT.Columns.Add("Remove");

#endregion

#region Table Rows

// ADDS ALL THE ORIGINAL DATA RECEIVED FROM DATATABLE TO NEW
REFORMATED DATATABLE
foreach (DataRowView myDRV in BottomDataView)
{
myNewBottomDR = myNewBottomDT.NewRow();

for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "fl_memo":
if ( myDRV.ToString() == "1" )
{
myNewBottomDR = "Yes";
}
else
{
myNewBottomDR = "No";
}
break;

default:
myNewBottomDR = myDRV.ToString();
break;
}

}

myNewBottomDT.Rows.Add(myNewBottomDR);
}

#endregion

// SIMPLY USED FOR TESTING PURPUSES ON MY END
//dg2.DataSource = myNewBottomDT;
//dg2.DataBind();

// ****
// PROBLEMATIC LINES BELLOW
// ****

myNewBottomDR = myNewBottomDT.NewRow();
myNewBottomDT.Rows.Add(myNewBottomDR);

// ****
// PROBLEMATIC LINES ABOVE
// ****

// SIMPLY USED FOR TESTING PURPUSES ON MY END
//dg3.DataSource = myNewBottomDT;
//dg3.DataBind();

myNewBottomDT.Columns.Remove("nm_planner");
myNewBottomDT.Columns.Remove("nm_commodity");
myNewBottomDT.Columns.Remove("cd_plnt_symb");
myNewBottomDT.Columns.Remove("id_evnt_num");
myNewBottomDT.Columns.Remove("nm_vendor");
myNewBottomDT.Columns.Remove("f_id_cmmt_seq");

// EDITABLE DATAGRID
DGPlanningStatusBottom.DataSource = myNewBottomDT;
DGPlanningStatusBottom.DataBind();

}

thank u guys for your help i realy appriciate it
 
K

Ken Cox [Microsoft MVP]

It is still hard to understand what you're trying to accomplish. Could you
post a serialized version of the original datatable?

Also, when you put a Try...Catch around the problematic lines, does it show
anything?


toytoto said:
Alvin, Ken, Sorry for the confusion and useless code in the previous
message, been doing so manythings to try to make this work it's not
even funny... anyway here's the problem and new clean code.

if i DON'T include the blank row in the datatable and bind this
datatable to an editable datagrid with a few checkbox's, dropdown's,
textbox's on it etc. When i make changes to any values eg: "select
different values in one of the dropdown's" then the postback occurs
and all proper events a triggered and working fine.

now if i include the blank row in the datatable and bind this
datatable to the same editable datagrid When i make changes to any
values eg: "select different values in one of the dropdown's" then the
postback DOESN'T occur anymore and NO events are triggered and the
page returns "Action Cancelled" page. I've tried a million different
things without success placed tonnes of bookmarks in the page and none
of them receive focus when i added this blank row in the datatable.

please feel free to email directly if additional "info" or "code"
needed

here is the entire method as i use it

private void FillBottomPlanningStatusTab(DataTable myBottomDT)
{
DataView BottomDataView = new DataView();

//myBottomDT IS THE DATATABLE RECEIVED WHEN THIS METHOD IS CALLED
BottomDataView.Table = myBottomDT;

DataTable myNewBottomDT = new DataTable("myNewBottomDT1");
DataRow myNewBottomDR;

#region Table Columns

// RENAMES THE NEEDED COLUMNS FROM RECEIVED DATATABLE
for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "id_futures":
myNewBottomDT.Columns.Add("Futures");
break;

case "id_planner":
myNewBottomDT.Columns.Add("Responsible");
break;

case "cd_commodity":
myNewBottomDT.Columns.Add("Commodity<BR>Service");
break;

case "tx_desc":
myNewBottomDT.Columns.Add("Description");
break;

case "qy_leadtime":
myNewBottomDT.Columns.Add("Lead Time");
break;

case "dt_planning_def":
myNewBottomDT.Columns.Add("Need Date");
break;

case "fl_memo":
myNewBottomDT.Columns.Add("Memo Only");
break;

case "qy_hrs_est":
myNewBottomDT.Columns.Add("Man Hrs Est");
break;

case "qy_hrs_act":
myNewBottomDT.Columns.Add("Man Hrs Act");
break;

case "cd_cmmt":
myNewBottomDT.Columns.Add("Type");
break;

case "id_cmmt":
myNewBottomDT.Columns.Add("Document #");
break;

case "id_vendor_no":
myNewBottomDT.Columns.Add("Vendor");
break;

case "id_po":
myNewBottomDT.Columns.Add("PO #");
break;

default:
myNewBottomDT.Columns.Add(BottomDataView.Table.Columns.ColumnName.ToString());
break;
}

}

myNewBottomDT.Columns.Add("Remove");

#endregion

#region Table Rows

// ADDS ALL THE ORIGINAL DATA RECEIVED FROM DATATABLE TO NEW
REFORMATED DATATABLE
foreach (DataRowView myDRV in BottomDataView)
{
myNewBottomDR = myNewBottomDT.NewRow();

for (int i = 0; i < BottomDataView.Table.Columns.Count; i++)
{
switch (BottomDataView.Table.Columns.ColumnName.ToString())
{
case "fl_memo":
if ( myDRV.ToString() == "1" )
{
myNewBottomDR = "Yes";
}
else
{
myNewBottomDR = "No";
}
break;

default:
myNewBottomDR = myDRV.ToString();
break;
}

}

myNewBottomDT.Rows.Add(myNewBottomDR);
}

#endregion

// SIMPLY USED FOR TESTING PURPUSES ON MY END
//dg2.DataSource = myNewBottomDT;
//dg2.DataBind();

// ****
// PROBLEMATIC LINES BELLOW
// ****

myNewBottomDR = myNewBottomDT.NewRow();
myNewBottomDT.Rows.Add(myNewBottomDR);

// ****
// PROBLEMATIC LINES ABOVE
// ****

// SIMPLY USED FOR TESTING PURPUSES ON MY END
//dg3.DataSource = myNewBottomDT;
//dg3.DataBind();

myNewBottomDT.Columns.Remove("nm_planner");
myNewBottomDT.Columns.Remove("nm_commodity");
myNewBottomDT.Columns.Remove("cd_plnt_symb");
myNewBottomDT.Columns.Remove("id_evnt_num");
myNewBottomDT.Columns.Remove("nm_vendor");
myNewBottomDT.Columns.Remove("f_id_cmmt_seq");

// EDITABLE DATAGRID
DGPlanningStatusBottom.DataSource = myNewBottomDT;
DGPlanningStatusBottom.DataBind();

}

thank u guys for your help i realy appriciate it
 

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

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top