Tuesday, January 31, 2012

Build view List item url and Edit List item url-sharepoint 2010



In this post we are going to programatically build view List item url and Edit List item url-sharepoint 2010.
Below is how the url's supposed to be .

View list item url::
http://<site url>/Lists/<ListName>/DispForm.aspx?ID=<ItemID>&Source=/Lists/<ListName>

Edit list item url::
http://<site url>/Lists/<ListName>/EditForm.aspx?ID=<ItemID>&Source=/Lists/<ListName>



Hope this helps...

Thursday, January 12, 2012

How to filter a DataTable using LINQ

Hi Friends,

In this post we are going to Filter a DataTable using LINQ.

We can filter a DataTable in many ways but using LINQ is the best and recommended approach..
In the below code snippet we are going to filter the datatable and then assign the results back to it.

Below are the assumptions before you jump into the code.
  • dtMainTable is the DataTable which you got it from your logic.

var tempTable = from DataRow dataRow in dtMainTable.Rows
                                    where dataRow["ColumnName"] == "Value"
                                    select dataRow;
                    if (tempTable.Count() > 0)
                    {
                        dtMainTable= tempTable.CopyToDataTable();
                        dtMainTable.AcceptChanges();
                    }

Hope this helps...

Popular Posts