Sunday, July 27, 2008

Temp table in asp.net

First create the data table and then give the definition for the column
DataTable myDataTable = new DataTable();
DataColumn myDataColumn;
DataRow myDataRow;
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.Int32");
myDataColumn.ColumnName = "FileId";
myDataColumn.ReadOnly = true;
myDataColumn.Unique = true;
myDataTable.Columns.Add(myDataColumn);

myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "FileName";
myDataColumn.ReadOnly = false;
myDataTable.Columns.Add(myDataColumn);

Now add the data in that table
myDataRow = myDataTable.NewRow();
myDataRow["FileId"] = i;
myDataRow["FileName"] = NameList[i].ToString();

myDataTable.Rows.Add(myDataRow);
When we delete any row then call the accept change method of the data table

No comments:

Post a Comment