Hello,
I want to create several links from one view control (lets call it contact.ascx). The view control does not need to list the contents of a given table. The various links direct the user to a particular page to add a new row in the respective table. As the links go to the various edit controls they data bind the page as they click to the edit control. I need an example of how to create one of those links?
This is what I have tried to implement without success.
<asp:DataList ID=dlcontact Runat ="server">
<ItemTemplate>
<asp:HyperLink NavigateUrl='<%# "Contact_ID",DataBinder.Eval(Container.DataItem,"Contact_ID") %>' Visible="<%# IsEditable %>" runat="server" ID="HLContact">
</asp:HyperLink>
</ItemTemplate>
</asp:DataList>
My data base has a parent table called ?Contact? with four child tables (contractor, roofer, source, and client). There are foreign key constraints on the tables. I tried to add a row to one of the child tables independent of the parent table and it didn?t work. I see that I?ll need to add a row to the parent table at the same time as I add a row to one of the children.
Below is an example of the parent child relationship between Contact and Roofer (I see now that Roofer has a redundant column with ?Name?). So what I am thinking I need to do is have an edit control that has been data bound to both tables. When the user clicks to the edit control in order to add a new contact of entity Roofer they see text field boxes for Name, address, city, etc etc but what they don?t know is that they are entering the name of the contact into the Contact Table and the particulars of that contact in the roofer table. Am I approaching/thinking about this correctly?
If I am planning this correctly then the link (Add New Roofer Contact) from the view control needs to data bind to both tables and I figure I will need to write a new stored procedure that updates with a join.
Contact Table |
Roofer Table |
|
|
Contact_ID |
Roofer_ID |
Name |
Contact_ID |
ModuleID |
Name |
PortalID |
Address |
DateAdd |
City |
DateMod |
Province |
|
Postal |
|
Phone |
|
Etc?.. |
Thank you in advance,
Doug
I organized my components so that everything is included in the info.vb and controller.vb files respectively. I can Dim all the data objects from the same Namespace (I?m not sure if I described that correctly).
So for example I tried this and it worked.
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports Techsbook.DNN.Modules.Associate.Business
Namespace Techsbook.DNN.Modules.Associate
Public MustInherit Class Associate
Inherits Entities.Modules.PortalModuleBase
Implements Entities.Modules.IActionable
Implements Entities.Modules.IPortable
Implements Entities.Modules.ISearchable
#Region "Controls"
#End Region
#Region "Event Handlers"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
'Sample code to get data
Dim objctlcontact As New ContactController
Dim objctlcontractor As New ContractorController
Dim objctlroofer As New RooferController
Dim objctlsource As New SourceController
Dim objctlclient As New ClientController
If Not Page.IsPostBack Then
rptContact.DataSource = objctlcontact.ListContact(ModuleId, PortalId)
rptContact.DataBind()
rptContractor.DataSource = objctlcontractor.ListContractor(ModuleId, PortalId)
rptContractor.DataBind()
rptRoofer.DataSource = objctlroofer.ListRoofer(ModuleId, PortalId)
rptRoofer.DataBind()
rptSource.DataSource = objctlsource.ListSource(ModuleId, PortalId)
rptSource.DataBind()
rptClient.DataSource = objctlclient.ListClient(ModuleId, PortalId)
rptClient.DataBind()
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents rptClient As System.Web.UI.WebControls.Repeater
Protected WithEvents rptSource As System.Web.UI.WebControls.Repeater
Protected WithEvents rptRoofer As System.Web.UI.WebControls.Repeater
Protected WithEvents rptContractor As System.Web.UI.WebControls.Repeater
Protected WithEvents rptContact As System.Web.UI.WebControls.Repeater
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
End Class
End Namespace
Best regards,
Doug