asp.net - Filter Gridview results using Linq to Sql Object datasource with a LIKE operator -


I have a gridview that is bound to LINQ from SQL data source. I want to filter results in Gridview using the LIKE operator. That is, I have a textbox to search on the username and I would like to select all users with the username [textbox value].

Below is my code:

  & lt; H1 & gt; Manage users & lt; / H1>  
Search for users Username:
  & lt; asp: GridView ID = "GridView2" runat = "server" permission Denpejing = "true" Allow Allow = "true" auto-generated columns = "false" Datasorsaidi = "LinqDataSource1" & gt; & Lt; Columns & gt; & Lt; ASP: Boundfild Detafild = "username" Hadertakst = "User Name" Reedonli = "true" Sortaksresian = "username" / & gt; & Lt; ASP: Boundfield Dated Field = "FullName" Header Text = "Full Name" Reed Olly = "True" SortXpress = "FullName" /> & Lt; ASP: BoundfieldDefined = "Email" HeaderText = "Email" readonly = "True" sortExpress = "email" /> & Lt; ASP: Boundfild Detafild = "Lastlogindet" header text = "last login" Reedonli = "true" sort Akspereshn = "Lastlagindet" Detaformat String = "{0: DD Mmmm justice}" / & gt; & Lt; ASP: HyperLinkField text = "edit" DataNavigateUrlFields = "user id" DataNavigateUrlFormatString = "? ~ / Page / UsersMaintenance / CreateEditUser.aspx UserId = {0}" / & gt; & Lt; / Column & gt; & Lt; / ASP: GridView & gt; & Lt; ASP: LinqDataSource ID = "LinqDataSource1" runat = "server" ContextTypeName = "AirProducts.BusinessLogic.AirProductsDataContext select" = "New (UserId, Username, Details.FullName, Membership.Email, Membership.LastLoginDate)" TableName = " User "ou =" user name == @username "& gt; & Lt; WhereParameters & gt; & Lt; Asp: ControlParameter ControlID = "txtUsername" name = "username" property name = "text" type = "string" /> & Lt; / WhereParameters & gt; & Lt; / ASP: LinqDataSource & gt; Text after "   

is equivalent to the operator with a call for the replacement String. Contains Where method in the section of your LINQ expression:

   & Lt; / WhereParameters & gt; & Lt; / ASP: LinqDataSource & gt;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -