Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Id's to items in DataRow

Status
Not open for further replies.

mais123

Programmer
Dec 26, 2007
36
US
Hi, I am creating a DataTable on the fly(basically converting html table to datatable). I need a way to assign unique ID's to each cell in DataRow. I dont see datacell object to which I can assign Id's. what is the way to do it?
Code:
 //create rows
            foreach (TableRow SourceTableRow in sourceTable.Rows)
            {
                DataRow OutputTableRow = outputTable.NewRow();
                //get data from cells
                for (int i = 0; i <= SourceTableRow.Cells.Count; i++)
                {
                    OutputTableRow[i] = SourceTableRow.Cells[i].Text;
                OutputTableRow[i].ID =   SourceTableRow.Cells[i].ID;  //OutputTableRow[i] does not have ID property!
                }
                //add row to table
                outputTable.Rows.Add(OutputTableRow);

            }

Thnaks!!
 
[tt]SourceTableRow.Cells.ID[/tt] is the [tt]Cell.ID[/tt] property. it has nothing to do with the data of the cell. the ID is used to create the unique id on the client.
Code:
<td id="MyTable$MyRow_1$MyCell_1">value goes here</td>
DataRow does not have an Id property because there is no need for it. the id of the row (PK usually) would just be another column in the row.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top