Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 12th, 2011, 02:37 AM
Registered User
 
Join Date: Jan 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default join two table with gridview

hi

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
Code:
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
Code:
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)
        sda.Fill(ds)
        ViewState("ds") = ds
        ActivityGV.DataSource = ds.Tables(0)
        ActivityGV.DataBind()
 End Sub
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 02: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



All times are GMT -4. The time now is 02:38 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.