How To Find Matching Values In A Generic List
May 25, 2010
I have anywhere from 5 to 10 generic list in an ASP.NET VB.NET web app. I would like to write a method to pass them all into, and return only the elements they all have in common.
View 2 Replies
Similar Messages:
Feb 4, 2011
I have a table Books with columns BookID, BookSummary, BookAuthor.
What I have stupidly done was to add a link to another url at the end of the BookSummary. Assuming the text is something like this:
This is a book about a love story in World War 2 in Europe. The book is written by Elliot James.
I have added
<a href='http=://XXXXXX'>Buy Book</a> at the end of the text making the final content of BookSummary to be like:
This is a book about a love story in World War 2 in Europe. The book is written by Elliot James.
<a href='http=://XXXXXX'>Buy Book</a>
I now need to write a code (via regex?) to read through each BookSummary, find the <a href='http://XXXXX'>Buy Book</a> and delete it. But the problem is the content in XXX could be anything and I cannot use typical string functions. Can anyone guide me to
achieve this using Regex?
View 7 Replies
Sep 20, 2015
For ex:
Grid 1
ID Name
1 aaa
2 bbb
3 ccc
Grid 2
ID Name
1 aaa
3 ccc
I want O/P in Grid 3:
2 bbb
View 1 Replies
Jan 15, 2010
I am trying to assign values I've gathered from a JSON feed to my own type, a class in which I have defined certain fields (properties) to put the JSON elements into, plus elements that are derived from a RegEx pattern matching process. This will then allow me to access the object using LINQ, as I am using a List to hold my objects. There is a foreach loop in my code that loops for each match that my RegEx method finds. I am only interested in the parts of the JSON feed where there is a match. So my own defined class is as such:
//simple field definition class
public class TwitterCollection
{
public string origURL { get; set; }
public string txtDesc { get; set; }
public string imgURL { get; set; }
public string userName { get; set; }
public string createdAt { get; set; }
}
And then I want to populate List in the RegEx Matches loop:
foreach (Match match in matches)
{
GroupCollection groups = match.Groups;
var tc = new List<TwitterCollection>()
{
origURL = groups[0].Value.ToString(),
txtDesc = res.text,
imgUrl = res.profile_image_url,
userName = res.from_user_id,
createdAt = res.created_at,
};
}
The code will then go on to extract and sort the results via Linq to Objects. But compiler won't actually let me create my var tc = new List<TwitterCollection>() because: 'System.Collections.Generic.List' does not contain a definition for 'origURL' ... even though I have defined it. It does not flag an error if I simply write new TwitterCollection but then how do I refer to this in my Linq expression later on??
View 3 Replies
Jan 21, 2011
So, have a search form where users can enter one or more keywords, these keywords are then held in a List<string> called keywords. Now using Entity Framework have an Organisation entity with a Name field. What I want to do is select those organisations whose name contains all the keywords. I don't care if they are in the right order or not but it just contain all the keywords. Also organsiations is a big table in the database so I don't want to materialise all the organsiation objects on the server and then loop through them. So what I'm looking for (excuse my LINQ naivety here) is equivalent to the non-existent LINQ statement:
[Code]....
I'm sure this must have already been answered but just can't find it.
View 6 Replies
Feb 6, 2010
I have the following Students class:
[Code]....
I need the 1 since it's a foreign key in another table. For the life of me, I can't get this to work like this.
View 7 Replies
Dec 20, 2010
I have this ASP.NET code:
<asp:DropDownList
ID="ddlBrokers"
runat="server"
AutoPostBack="true"
DataSourceID="srcBrokers"
DataTextField="broker"
DataValueField="brokerId"
/>
<asp:ObjectDataSource
id="srcBrokers"
TypeName="DatabaseComponent.DBUtil"
SelectMethod="GetBrokers"
runat="server">
</asp:ObjectDataSource>
My DAL code:
public DataTable GetBrokers(bool? hasImport=null)
{
SqlCommand cmd = new SqlCommand("usp_GetBrokers");
if (hasImport.HasValue)
cmd.Parameters.AddWithValue("@hasImport", hasImport);
return FillDataTable(cmd, "brokers");
}
When the form loads I get this error:
ObjectDataSource 'srcBrokers' could not find a non-generic method 'GetBrokers' that has no parameters.
Is it my optional parameter that is causing the problem? How can I workaround this? Is it possible to have optional parameters with declarative ASP.NET code?
View 1 Replies
Mar 7, 2011
I am binding dropdown list using Object data source. I got an error like this
"ObjectDataSource 'objDSStatus' could not find a non-generic method 'GetIssueAllowedStatusByCategoryIDStatusIDandUserType' that has parameters: IssueCategoryID."
My code is as follows .aspx
< asp:DropDownList ID="ddlStatus" runat="server" DataSourceID="objDSStatus"
DataTextField="IssueStatusName" DataValueField="IssueStatusID">
< /asp:DropDownList>
< asp:ObjectDataSource ID="objDSStatus" runat="server" TypeName="DA"></asp:ObjectDataSource>
.cs
private void Bind(int IssueCategoryID, int IssueStatusID, int UserType)
{
ddlStatus.Items.Clear();
objDSStatus.SelectMethod = "GetIssueAllowedStatusByCategoryIDStatusIDandUserType";
objDSStatus.SelectParameters.Clear();
objDSStatus.SelectParameters.Add("IssueCategoryID", IssueCategoryID.ToString());
objDSStatus.SelectParameters.Add("IssueStatusID", IssueStatusID.ToString());
objDSStatus.SelectParameters.Add("UserType", UserType.ToString());
objDSStatus.DataBind();
ddlStatus.DataBind();
}
DA.cs
public List<IssueStatus> GetIssueAllowedStatusByCategoryIDStatusIDandUserType(int IssueeCategoryID, int IssueStatusID, int UserType)
{
List<IssueStatus> issueStatusList = new List<IssueStatus>();
}
View 2 Replies
Nov 25, 2010
I'm a starting C# programmer and I'm experiencing the following problem.I've created a dataset in Visual Studio With a table for persons making use of two table adapters, one for selecting all persons and one for selecting one person at a time filtered by the personID (Guid). This is a seperate project of my solution. After that I created a new project for the Business Logic Layer
private PersonenTableAdapter personenAdapter = null;
protected PersonenTableAdapter Adapter
{get....}
[System.ComponentModel.DataObjectMethodAttribute (System.ComponentModel.DataObjectMethodType.Select, true)]
public DAL.Testdatabase.PersonenDataTable GetPersonen()
{...}
[System.ComponentModel.DataObjectMethodAttribute (System.ComponentModel.DataObjectMethodType.Select, false)]
public DAL.Testdatabase.PersonenDataTable GetPersonenByID(Guid ID)
{...}
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
public bool updatePersoon(string Voornaam, string Achternaam, string Geslacht, string Adres, string Huisnr, string Postcode, string Plaats, string Telnr, string GSM, string BSN, DateTime? CreateDate, string CreatedBy, DateTime? LastModifiedDate, string LastModifiedBy, bool? Actief, DateTime? DatumInactief, Guid ID)
{...}
When issueing the Update method using a detailsview with an Objectdatasource i get the following error.
ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'updatePersoon' that has parameters: Voornaam, Achternaam, Geslacht, Adres, HuisNr, Postcode, Plaats, Telnr, GSM, BSN, CreateDate, CreatedBy, LastModifiedDate, LastModifiedBy, Actief, DatumInactief, original_ID.
View 1 Replies
Sep 24, 2010
Code:
<asp:GridView ID="ProductsGrid" runat="server" AutoGenerateColumns="False" DataKeyNames="ID,UserId"
DataSourceID="ProductsOptimisticConcurrencyDataSource"
OnRowUpdated="ProductsGrid_RowUpdated" AllowPaging="True" AllowSorting="True"
EnableModelValidation="True">
<Columns>
<asp:CommandField ShowDeleteButton="True" ValidationGroup="InsertValidationControls" />
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID"
ReadOnly="True" InsertVisible="False" />
<asp:BoundField DataField="UserId" HeaderText="UserId" ReadOnly="True"
SortExpression="UserId" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ProductsOptimisticConcurrencyDataSource" runat="server"
ConflictDetection="CompareAllValues"
SelectMethod="GetZaposleniBy" TypeName="zaposleni"
OnDeleted="ProductsOptimisticConcurrencyDataSource_Deleted"
OnUpdated="ProductsOptimisticConcurrencyDataSource_Updated"
onselecting="ProductsOptimisticConcurrencyDataSource_Selecting"
DeleteMethod="DeleteProduct">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
</asp:ObjectDataSource>
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Delete, true)]
public bool DeleteProduct(int ID)
{
Guid UserId = Guid.NewGuid();
int rowsAffected = Adapter.Delete(ID,UserId);
// Return true if precisely one row was deleted, otherwise false
return rowsAffected == 1;
}
The problem is when I use Guid UserId = Guid.NewGuid ();.
In Table I UserId type: unique Therefore it does not work. If I use the UserId type: int working.
Error:
ObjectDataSource 'ProductsOptimisticConcurrencyDataSource' could not find a non-generic method 'DeleteProduct' that has parameters: ID, UserId.
Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: ObjectDataSource 'ProductsOptimisticConcurrencyDataSource' could not find a non-generic method 'DeleteProduct' that has parameters: ID, UserId.
Source Error:
[Code]....
Stack Trace:
[Code]....
[InvalidOperationException: ObjectDataSource 'ProductsOptimisticConcurrencyDataSource' could not find a non-generic method 'DeleteProduct' that has parameters: ID, UserId.]
System.Web.UI.WebControls.ObjectDataSourceView.GetResolvedMethodData(Type type, String methodName, IDictionary allParameters, DataSourceOperation operation) +1119426
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) +504
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +89
System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) +714
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +869
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +207
System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565a
View 2 Replies
Feb 3, 2010
I am getting error : ObjectDataSource 'ObjectDataSource1' could not find a non-generic method What would be the possible cause / solution for this error.This error is coming when call below method ObjectDataSource1.SelectMethod = "MethodName"// thr r some more code after that, although not much irrelevant
en call Server.Transfer("NewPage.aspx", True);
View 2 Replies
Apr 29, 2010
Is there a generic control that can be added to all aspx pages that checks for silverlight plugin and the version.. I know there is javascript and the silverlighthost object tag that accomplishes this. Is there an existing ascx control that wraps this functionality ? I need to be able to set the path to the xap on each page (via a property on the ascx control).
View 2 Replies
Mar 11, 2010
error "ObjectDataSource 'ObjectDataSourceCaseDetails' could not find a non-generic method". I have an update method and my ObjectDataSource is hooked up to the method in my BLL. review my code below
[Code]....
[Code]....
View 1 Replies
Jan 3, 2011
I have a list view control. Each row within it has a rowid and a textbox where a note(user enters relevant info to that particular record) is entered. On a paging event I store the rowID and the note text in a generic list for retrieval if the user pages back later on. Goal here is to keep the text the user has entered. (see the code below)This generic list does in fact get populated correctly when I go to the next page currently. I can see this in Visual Studio. So now, when the user goes back to the first page I want to run a test within my Listviews ItemDataBound event. I want to see if the row ID being tested is part of the generic list. If so, I then want to take the corresponding note that is also within the list and bind it to the text box. However, I don't know how to write the correct conditional for this and how to bind the textbox if the conditional evaluates to true.
View 1 Replies
Jan 26, 2011
I try to update the detailview control. got this error messsage.
ObjectDataSource 'odsDetail' could not find a non-generic method 'Update' that has parameters: hospitalID, hospitalName, taxID, address1, address2, city, state, zip.
[Code]....
here's my edit function
[Code]....
View 3 Replies
Nov 22, 2015
I have a scenario which is the row will be highlighted if that row have the same data.
View 1 Replies
Apr 7, 2010
I have two generic list with Hotel class object. Both List contains hotel ID. I want to retrieve common hotel id from both Hotel List and assign to new HotelList.I have done following code for that but any other sort way to implement this kind of functionality.
[Code]....
Note: I dont want to use Linq because I am working on framwork 2.0
View 1 Replies
Aug 4, 2010
I'm trying to render out some images on an aspx page. Error I'm getting in the code below is:
DataBinding: '_Default+ImageThing' does not contain a property with the name 'FileName'.
public class ImageThing
{
public string FileName;
}
private void DisplayThumbnailImages()
{
ImageThing imageThing1 = new ImageThing();
ImageThing imageThing2 = new ImageThing();
imageThing1.FileName = "asdf.jpg";
imageThing2.FileName = "aaa.jpg";
List<ImageThing> imagesToRender = new List<ImageThing>();
imagesToRender.Add(imageThing1);
imagesToRender.Add(imageThing2);
Repeater1.DataSource = imagesToRender;
Repeater1.DataBind();
}
here is the aspx:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "FileName")%>
</ItemTemplate>
</asp:Repeater>
View 3 Replies
Jan 19, 2011
in my model there is a List.
public class InvoiceModel{
public int InvoiceID { get; set; }
public int Date { get; set; }[code]...
for create view i can use Html.TextBoxFor(m => m.InvoiceID) and for Date.but how can i fill List?and how can i use global for this list as Shopping cart?
View 6 Replies
Jan 8, 2010
Most likely the later, I think. In my page I have a GridView, DatailsView, and the ODS. None of my commands work. For the Udate command I get a an error "ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'UpdateVirtual' that has parameters: name, notes, active, original_ident." For the Delete command I get "ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'DeleteVirtual' that has parameters: ident, original_ident." Yet the Insert command in the DetailsView works fine. Originally I've copied a file that performs virtually identical task, the only difference is a different database and the Select command. I had the Delete command working for for while but that one too broke. Can someone point out what I'm doing wring?
Below is the code:
The *.aspx file:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Maintain_Virtual_Users.aspx.cs" Inherits="Maintain_Virtual_Users" Title="Maintain Accounts" StylesheetTheme="Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h2>
Maintain Virtual Users</h2>
<p>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="ident"
DataSourceID="ObjectDataSource1" AutoGenerateDeleteButton="false"
AutoGenerateEditButton="False">
<Columns>
<asp:BoundField DataField="ident" HeaderText="ident" SortExpression="ident"
ReadOnly="True" />
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
<asp:BoundField DataField="notes" HeaderText="notes" SortExpression="notes" />
<asp:CheckBoxField DataField="active" HeaderText="active"
SortExpression="active" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
</Columns>
</asp:GridView>
</p>
<p>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="ident"
DataSourceID="ObjectDataSource1" Height="50px" Width="393px"
DefaultMode="Insert" AutoGenerateInsertButton="False">
<Fields>
<asp:BoundField DataField="ident" HeaderText="ident" ControlStyle-Width="250"
SortExpression="ident" ReadOnly="True" >
</asp:BoundField>
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
<asp:BoundField DataField="notes" HeaderText="notes" SortExpression="notes" />
<asp:CheckBoxField DataField="active" HeaderText="active"
SortExpression="active" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="DeleteVirtual" InsertMethod="AddVirtual"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetVirtual"
TypeName="VirtualPeopleBLL" UpdateMethod="UpdateVirtual">
<DeleteParameters>
<asp:Parameter Name="ident" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ident" Type="Int32" />
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="notes" Type="String" />
<asp:Parameter Name="active" Type="Boolean" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ident" Type="Int32" />
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="notes" Type="String" />
<asp:Parameter Name="active" Type="Boolean" />
</InsertParameters>
</asp:ObjectDataSource>
</p>
</asp:Content>
the .BLL:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using dsVirtualPeopleTableAdapters;
[System.ComponentModel.DataObject]
public class VirtualPeopleBLL
{
private VirtualPeopleTableAdapter _virtualPeopleAdapter = null;
protected VirtualPeopleTableAdapter Adapter
{
get
{
if (_virtualPeopleAdapter == null)
_virtualPeopleAdapter = new VirtualPeopleTableAdapter();
return _virtualPeopleAdapter;
}
View 2 Replies
Aug 17, 2010
Can any one can describe the main diffrence between the array and generic list.
View 6 Replies
Apr 7, 2010
I have one Hotel class that contains many properties. When I retrieve all hotels data from database, I store them in Generic List object.Now what I want that I have two properties called LowestPrice and HiestPrice. I want to get Minimum(LowestPrice) and Maximum(HiestPrice) from generic list directly.
Something like HotelList.Min();
Right now I have following logic implemented in my project, but I dont want to use foreach loop.
[Code]....
View 6 Replies
Aug 1, 2010
I have a list of Categories which I need to bind to a TreeView control in WPF and I can't find a working tutorial or get it working.My Category class consist of (ID, Title, ParentID). If the Category is a top level category the parentID is null.Can anyone sow me how to bind this to a treeview?
View 3 Replies
Nov 23, 2010
I have declared a simple class
[Code]....
And Pass some values to it :
[Code]....
Then I use Linq to select rows :
[Code]....
How I can enumerate it?! I used this, but it has error
[Code]....
View 3 Replies
Jun 25, 2010
I am using datalist to bind the generic list. On databind() command I am getting error "nable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
View 3 Replies