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