Wrox Programmer Forums
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 12th, 2011, 03:37 AM
Registered User
Join Date: Jan 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default join two table with gridview


i have web page that save data for stores. These stores have activities, i want to determine the activities for those stores using gridview and dropdownlist. so i make three tables:
- first one is tbOLActivity table:
has fields:
ActivityId int (pk), ActivityName nvarchar(50)
- second one is tbOLStore table:
has fields:
StoreId int (pk), StoreName nvarchar(50), ActivityId int (fk), Address navrchar(50)
-therd one is tbOLStoreActivty table:
has fields :
SerialNo int (pk), StoreId int (fk), ActivityId int (fk), Activity_Status int
i drag dropdownlist in web page called "AcivityCombo" to display the availble activity data
If CtvAct.GetRecords("Fill_ActivityTb") = True Then                 AcivityCombo.DataSource = CtvAct.MainDataset.Tables("tbOLActivity").DefaultView                 AcivityCombo.DataTextField = "ActivityName"                 AcivityCombo.DataValueField = "ActivityId"                 AcivityCombo.DataBind()
and gridview to show the selected activity
the problem is how to select item from this combo and insert it into gridview then save data into the tables
i try this code but it dose not work
Protected Sub AddActivityCnd_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles AddActivityCnd.Click
 Dim sda As New SqlDataAdapter("SELECT dbo.tbOLStoreActivty.StoreId, dbo.tbOLStoreActivty.ActivityId, dbo.tbOLActivity.ActivityName FROM  dbo.tbOLActivity INNER JOIN dbo.tbOLStoreActivty ON dbo.tbOLActivity.ActivityId = dbo.tbOLStoreActivty.ActivityId WHERE tbOLStoreActivty.ActivityId='" & Trim(AcivityCombo.SelectedValue.ToString) & " ' ", con)
        ViewState("ds") = ds
        ActivityGV.DataSource = ds.Tables(0)
 End Sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
join two table with gridview yousof BOOK: Beginning ASP.NET 4 : in C# and VB 2 January 12th, 2011 03:41 AM
table join problem ankurkumar ASP.NET 3.5 Basics 4 July 27th, 2009 09:39 AM
table join debbiecoates SQL Server 2000 2 July 2nd, 2008 01:39 PM
can i make self join table seco MySQL 1 April 18th, 2007 11:17 PM
could i join function(return table) with a table alyeng2000 SQL Server 2000 6 September 30th, 2004 07:23 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.