Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Linq Where issue in C#

$
0
0

I have a Session variable that holds an event id and an eventdatetime. I display this informatin in a table. I also have a delete button coded in. If the user delete a specific date, I want to remove it from my session for that list. I run the code below and instead of removing that one record, it sets the EventDateTimeList to count 0. What am I doing wrong?

protected void btnDeleteRole_Click(object sender, CommandEventArgs e)
        {
            // 0 - eventId | 1 - eventDateTime
            string[] splitCommandArgument = e.CommandArgument.ToString().Split(';');

            var eventId = Guid.Parse(splitCommandArgument[0]);
            var eventDateTime = Convert.ToDateTime(splitCommandArgument[1]);
            Response.Write(string.Format("EventID: {0} | EventDateTime: {1}", splitCommandArgument[0], splitCommandArgument[1]));



            SessionManager.EventDateTimeMain.EventDateTimeList = SessionManager.EventDateTimeMain.EventDateTimeList.Where(x=> x.EventId != eventId &&
                                                                                                                              x.EventDateTime != eventDateTime)
                                                                                                                   .Select(x=>x)
                                                                                                                   .ToList();
            MakeTable();

        }




Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>