Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Store data from a datagrid?


Message #1 by Philo <philo@r...> on Wed, 31 Jul 2002 04:04:44 -0400
Alright, this is kicking my ass -

I'm trying to get the data from a datagrid on postback, manipulate it 
(specifically add blank rows), then rebind.

I can get the data out, and I *think* it's getting into the datatable, but 
then it's not rebinding right.

Can someone help?

(the datagrid is built with template columns with textboxes for bulk data 
entry)

int addLines=10;
DataTable dt=new DataTable();
for(int i=0; i<POItems.Columns.Count; i++)
{
         dt.Columns.Add(");
}

DataGridItem dgi;
DataRow dr;

for(int i=0; i<POItems.Items.Count; i++)
{
         dgi=POItems.Items[i];
         dr=dt.NewRow();
         TextBox tb=(TextBox)dgi.FindControl("BuyerPartNbr");
         dr[0]=tb.Text;
         tb=(TextBox)dgi.FindControl("VendorPN");
         dr[1]=tb.Text;
         dt.Rows.InsertAt(dr, i);
}

DataRow newRow;

for(int i=0; i<addLines;i++)
{
         newRow=dt.NewRow();
         dt.Rows.Add(newRow);
}
POItems.DataSource=dt;
POItems.DataBind();


Thanks,
Philo


  Return to Index