Wrox Programmer Forums
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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, 01:30 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

Last edited by yousof; January 12th, 2011 at 01:48 AM..
Old January 12th, 2011, 03:00 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

Can you please post questions that are not directly related to my book in a more general category on ASP.NET here: http://p2p.wrox.com/asp-net-4-539/

Makes it easier for others to join the discussion and for readers of this category to find what they are looking for.


Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Old January 12th, 2011, 03:41 AM
Registered User
Join Date: Jan 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

ok no prblem
i'm sorry

Similar Threads
Thread Thread Starter Forum Replies Last Post
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
Join table puzzle... vanjamier SQL Language 1 November 26th, 2004 04:43 AM
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.