开发者

gridview filtering via joined tables

开发者 https://www.devze.com 2023-01-20 13:04 出处:网络
I\'m trying to display data which comes from a join on two tables (or more) in a gridview I want to be able to filter the result set via user given input (text boxes on page)
  1. I'm trying to display data which comes from a join on two tables (or more) in a gridview
  2. I want to be able to filter the result set via user given input (text boxes on page) I have tried the standard tutorials but cannot find something which goes beyond displaying one table result sets in the gridview. If I go through the configure gridview and configure datasource wizard for any datasource (sqlDatasource, object, entitydatasource), when I use multiple tables I cannot use the 'where' parameters in the wizard, and therefore need to have the selecting code in the code-behind, but i'm unsure where exactly to put this.

e.g. if I have

Protected Sub button1_Click(ByVal sender As Object, _
                            ByVal e As System.EventArgs) Handles button1.Click

   sqldatasource1.selectcommand = "select * from yourtable where modelfamily
       like '%" & textbox1.text & "%' or description like '%" & 
       textbox1.text & "%'"
   sqldatasource1.databind()
End Sub

then this code will help with a search button for part 2 of my question, e.g. if button1 is a search button then I can incorporate the text box values in the query 开发者_开发知识库and bind, but where would I place the intiial data binding code, in page_load? And where shall I place the other other code? Please could you provide me a link to a solution, or better help me here please.

I want to be able to:

  1. use entity data source to do this (how can I do this multiple join in entity framework, or other source if much easier)
  2. I want to display all the results intially (coming from two tables) with paging and sorting enabled
  3. if text box has a value and search button clicked, then subset of the data based on the value is shown, and is also page-able/sort-able within itself.

Please can you show me examples of where would the code sit, which events and what will it look like?


Have a look at this Inner Join statement and gridview

0

精彩评论

暂无评论...
验证码 换一张
取 消