views:

15

answers:

1
  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?

A: 

Have a look at this post.

Hope it helps!

Lorenzo
Thanks for the reply. However, i'm more looking for how to get the extra 'WHERE' bit into a join in the code behind and which stages/events the data source needs to be set in and the databind() called, and how exactly to set it . Ideally, entity framework examples, or object or sqlserver data sources. THanks.
Dave