Friday, March 20, 2009

options for a Question and Tips of DataTable and DataView

lblQ.Text = "what is the result of the following equation?";
Panel1.Controls.Add(lblQ);
rdOptions.Items.Add(First(dt.Rows[intOpt][2].ToString()));
rdOptions.RepeatDirection = RepeatDirection.Horizontal;
rdOptions.RepeatLayout = RepeatLayout.Table;
rdOptions.RepeatColumns = 2;
rdOptions.Width = 400;
rdOptions.CellSpacing = 3;
rdOptions.CellPadding = 3;
Panel1.Controls.Add(rdOptions);


Rowfilter on DT using DataView
-------------------------------
DataView dvSearchResults = dt.DefaultView;
dvSearchResults.RowFilter = "Name LIKE " + "'" + lastname + "%" + "'";

Removing the rows in the column 'Name' containing "Unknown"
------------------------------------------------------------
DataRow[] unknownRecords=ResultsTable.Select("Name='Unknown *'");
foreach(DataRow drUnknownRecs in unknownRecords)
ResultsTable.Rows.Remove(drUnknownRecs);

Querying using DataRow[] object and select Method(XYZ- col name)
--------------------------------------------------
DataRow[] flagDeletedRecords=dtChildActivity.Select("XYZ=1");

Like Operator in DataTable using DataTable.Select
------------------------------------------------
Select("Code LIKE '" + lastWord + "%'" );

No comments: