I am not so familiar with c# or asp.net. If you have a solution, please keep this in mind when explaining.
I am using DNN and Evoq. I have created a new module using Module Creator. I need to access my table (Test_Table). This table is internal it's part of DNN/Evoq database. I can access it when i go to Evoq (CMS), settings, SQL Console. (Example: Select * from Test_Table) The table is set up correctly.
These are the starter files I got when i created the module: View.ascx, View.ascx.cs and In App_LocalResources View.ascx
My Question.
How do i get the table values for Test_Table, a table that is not external but part of DNN/Evoq database. There is also no security / login requirements for this table.
Code on: View.ascx.cs
#region Using Statements
using System;
using DotNetNuke.Entities.Modules;
#endregion
namespace TestFormSupport1.MyTestFormSupport1
{
public partial class View : PortalModuleBase
{
#region Event Handlers
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
cmdSave.Click += cmdSave_Click;
cmdCancel.Click += cmdCancel_Click;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!Page.IsPostBack)
{
txtField.Text = (string)Settings["field"];
}
}
protected void cmdSave_Click(object sender, EventArgs e)
{
ModuleController.Instance.UpdateModuleSetting(ModuleId, "field", txtField.Text);
DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Update Successful 3", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess);
}
protected void cmdCancel_Click(object sender, EventArgs e)
{
}
#endregion
}
}
Code on View.ascx
<%@ Control Language="C#" AutoEventWireup="false" Inherits="TestFormSupport1.MyTestFormSupport1.View" CodeFile="View.ascx.cs" %>
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>
<div class="dnnForm dnnEdit dnnClear" id="dnnEdit">
<fieldset>
<div class="dnnFormItem">
<dnn:label id="plField" runat="server" text="Field" helptext="Enter a value" controlname="txtField" />
<asp:textbox id="txtField" runat="server" maxlength="255" />
</div>
</fieldset>
<ul class="dnnActions dnnClear">
<li><asp:linkbutton id="cmdSave" text="Save" runat="server" cssclass="dnnPrimaryAction" /></li>
<li><asp:linkbutton id="cmdCancel" text="Cancel" runat="server" cssclass="dnnSecondaryAction" /></li>
</ul>
</div>
Thanks in advance
DNN has different possibilities to access data - DAL, DAL+ and DAL2 (which is the "newest" one). To find an example read Using DAL 2 in a real world module.