asp.net - Using <asp:EntityDataSource> -


I am using EntityDataSource control to display data in the grid, I do the same EntityDataSource to display all data Search is the way to use, the problem is that I can only do one thing or it can be used to get the whole data or to get the whole data

This is my .aspx page

  & lt; asp: EntityDataSource id = "InvestorsSource" runat = "server" ConnectionString = "name = units" DefaultContainerName = "units" EnableFlattening = "false" EntitySetName = "investors" EntityTypeFilter = "Investors in =" select "it. [InvestorId] it. [. InvestorName], it [summary], this [logo], it [EmailAddress], it [PHONENUMBER], this [website] "AutoGenerateWhereClause =" right "orderBy =" this [InvestorName] "& gt .. ... & Lt; WhereParameters & gt; & Lt; Asp: FormParameter FormField = "txtSearchInvestor" name = "investor name" type = "string" /> & Lt; / WhereParameters & gt; & Lt; / ASP: EntityDataSource & gt; & Lt; ASP: textbox id = "textile explorer" run = "server" & gt; & Lt; / Asp: text box & gt; & Lt; ASP: Button ID = "Button 1" Run = "Server" Text = "Go" onclick = "button1_lick" /> & Lt; P & gt; & Lt; Asp: GridView ID = "gvInvestors" runat = "server" AllowPaging = "right" AllowSorting = "right" AutoGenerateColumns = "false" DataSourceID = "InvestorsSource" & gt; & Lt; Columns & gt; & Lt; ASP: Boundfild Detafild = "Niveskaidi" header text = "Niveskaidi" Reed Oli = "true" sort Akspereshn = "Investraidi" / & gt; & Lt; ASP: BoundField DataField = "InvestorName" HeaderText = "InvestorName" SortExpression = "InvestorName" ReadOnly = "true" /> & Lt; ASP: Boundfield datedfield = "summary" headerText = "summary" sortexpress = "summary" readonly = "true" /> & Lt; ASP: Boundfield datedfield = "email address" header text = "email address" sort.xpress = "email address" read online = "true" /> & Lt; ASP: Boundfield datedfield = "phone number" header text = "phone number" sortExpress = "phone number" readonly = "true" /> & Lt; ASP: BoundfieldDefined = "website" header text = "website" ordered expression = "website" readonly = "true" /> & Lt; / Column & gt; & Lt; / ASP: GridView & gt; & Lt; / P & gt;  

thanks

I set up a page using Northwind DB To do data boards using the Employee's Table, there are a text box control and button controls like your code. When the text box is empty all records are displayed. When an employee ID is entered in the text box and the 'Filter' button is clicked, only the employee is displayed with the employee (when present in the data). I think this is such a behavior that you are asking. Here's the markup:

  & lt; Form id = "form1" runat = "server" & gt; & Lt; Div & gt; & Lt; asp: EntityDataSource ID = "EntityDataSource1" runat = "server" connection string = "name = NWEntities" DefaultContainerName = "NWEntities" EntitySetName = "employee set" EntityTypeFilter = "employee" automatically generated Krenvhaanclojh = "true" select = "this. [Employee], [.] [Last name], this. [First name], this. [Title], this [title of the cousse], this [birthday]. "& Gt; & Lt; WhereParameters & gt; & Lt; Asp: FormParameter FormField = "txtFilter" name = "EmployeeID" type = "int32" /> & Lt; / WhereParameters & gt; & Lt; / ASP: EntityDataSource & gt; & Lt; ASP: Text Box ID = "TextFilter" Runat = "Server" /> & Lt; ASP: Button Runat = "Server" Text = "Filters" / & gt; & Lt; ASP: GridView id = "gvEmployees" runat = "server" DataSourceID = "EntityDataSource1" AutoGenerateColumns = "true" /> & Lt; / Div & gt; & Lt; / Form & gt; Edit  

Edit: has been raised as a question that to get all values ​​starting with the value entered as part of the value How to enter the filter text box for can be entered. You can use the same SQL operator and users should be told that the "%" character is wildcard, I have changed the filter to the FirstName field, here are changes made in the above code:

In the EntityDataSource tag:

  auto generate whereClause = "false" where = ". [First name] @firstname"  

WhereParameters in the tag :

  & asp: FormParameter FormField = "txtFilter" name = "firstname" type = "string" defaultValue = "%" />  

Now, when "n%" is entered in the filter text box, all records of the first name, starting with "n" will be displayed. A valid choice section can now be used.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -