Select Value between two column from datatable

I have a datatable. I need to fetch a certain column value based on the user input. For example, lets say the datatable has three column intpkdata,intFrom,intTo
Here is my some code,

                drCurrentRow = dtCurrentTable.NewRow();
                drCurrentRow["intpkdata"] = new Random().Next(0, 99999).ToString();
                drCurrentRow["intFrom"] = txtFrom.Text;
                drCurrentRow["intTo"] = txtTo.Text;

                ViewState["Pcidata"] = dtCurrentTable;
                gdvpciData.DataSource = dtCurrentTable;

Requirement :

if intFrom/intTo data is already exist in datatable then msg should come.Pleas see the image for records

enter image description here

OData queries and types other than IQueryable in ASP.NET Web API

I am building an ASP.NET Web API application that returns an Atom or an RSS feed. To do this, it builds a System.ServiceModel.Syndication.SyndicationFeed and a custom MediaTypeFormatter is responsible for handling the HTTP Accept Header, converting the SyndicationFeed to either an Atom10FeedFormatter or an Rss20FeedFormatter, and streaming the result to the response stream. So far, so good.

My controller looks something like this:

    public class FeedController : ApiController
        public HttpResponseMessage Get()
            FeedRepository feedRepository = new FeedRepository();
            HttpResponseMessage successResponseMessage = new HttpResponseMessage(feedRepository.GetSyndicationFeed());
            return successResponseMessage;

What I would like to do is make use of the built-in OData querying to filter my feed, but changing the return type of the Get() method to IQueryable obviously will not work since a SyndicationFeed does not implement IQueryable.

Is there a way to use the built in OData querying on the IEnumerable property on the SyndicationFeed?

How do I order by lastname? [duplicate]

This question already has an answer here:

How do I order my list with people alphabetical? I have the people randomly in a list but I want it to be alpabetical ordered. How do I do that?

Here is my code:

@if (ViewBag.Roles.CanModify)

Sleep naar een groep om deze toe te voegen


Lambda or LinQ expression to remove certain objects from List

I have a cart.Lines List and want to remove all items where quantity == 0

This is a list that holds collection of CartLine objects:

public class Cart
    private IList lines = new List();
    public IList Lines { get { return lines; } set { lines = value; } }

public class CartLine
    Product Product {get; set;}
    int Quantity {get; set;}


So something like:

cart.Lines.RemoveAll(x => x.Quantity == 0)

I only get Remove and RemoveAt, not RemoveAll !

Also can’t remove in a foreach loop, get error:
Collection was modified; enumeration operation may not execute.

I have now managed to do it with this code, surely there must be something more efficient ?

var myList = cart.Lines.ToList();
myList.RemoveAll(x => x.Quantity == 0);
cart.Lines = myList;

Okay Problem solved!Thanks guys, this here does it:

cart.Lines = cart.Lines.Where(x => x.Quantity != 0);

Remove an item from a LINQ collection

I think I am putting my question correctly 🙂

I am querying the database using LINQ to retrieve some data. Please find the code below.

var leadtasktype = _context.LeadTypeTaskTypes.Where(l => l.LeadTypeId == item.Value);

foreach(LeadTypeTaskType l in leadtasktype){
    if (l.TaskTypeId == 21)
        //I need to remove an item which has the tasktype id 21

As I mentioned in the comments, I need to remove items from the leadtasktype based on my if condition. How do I do this?