Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ModuleId returns 0ModuleId returns 0
Previous
 
Next
New Post
8/31/2007 8:10 AM
 

I am developing a very simple module for DNN 4.5.5, where i am using a RadGrid (latest version) and an ObjectDataSource. Select, Update and Delete is working perfectly, but when I do a PerformInsert, the ModuleId returns 0 (integer). How can I retrieve the ModuleId when I insert new data to the database? I am using this article http://adefwebserver.com/DotNetNukeHELP/DNN_Things4Sale/  as a template for my module.

 
New Post
8/31/2007 12:31 PM
 

With the RadGrid are you using the AllowAutomaticInserts="True" parameter?  If so, you'll need to expose the ModuleID to some control so the client side can see it.  Typically, you just call ModuleID in your codebehind and everything is fine.  With the Telerik RadGrid, though, you are not going to the codebehind to do the insert, so it doesn't know the moduleid.  The easiest thing to do is set the moduleid somewhere else in your module and let the RadGrid know about it.  I recommend just dropping a label above or below your grid and setting the text property of that label to your moduleid.  Set visibility for the label to False and your users won't see it.

In your codebehind on page load, do something like Label1.Text = ctype(ModuleID, String)

That will expose the moduleid to your ascx page through the Label1 text property.

Then in your ObjectDataSource (btw, I would use SQLDataSource if your are using SQL Server), just tell the Insert command where to find the moduleid.

<InsertParameters>
     <asp:ControlParameter ControlID="Label1" Name="moduleid" PropertyName="Text" Type="Int16" />
</InsertParameters>

 
New Post
8/31/2007 1:19 PM
 

Thanks, but your solution did not help. I also tried to use an SqlDataSource, but I am not experienced enough, so I try to stick to the documets written by Michael Washington... If I give you some of my code, maybe you see what's wrong. I guess I have been troubleshooting for too long, so I'm getting blinded by the code. 

Here is the insert code of the controller file:

        <DataObjectMethod(DataObjectMethodType.Insert)> _
        Public Shared Sub QBirthdayToday_Insert(ByVal BirthdayTodayInfo As QBirthdayTodayInfo)
            'Dim intModuleId As Integer
            DataProvider.Instance().ExecuteNonQuery("Q_spAddIndividual", BirthdayTodayInfo.ModuleId, GetNull(BirthdayTodayInfo.IndividualFirstName.ToString), GetNull(BirthdayTodayInfo.IndividualLastName.ToString), GetNull(BirthdayTodayInfo.Individual.ToString), GetNull(BirthdayTodayInfo.Day), GetNull(BirthdayTodayInfo.Month), GetNull(BirthdayTodayInfo.Year), GetNull(BirthdayTodayInfo.IsLiving))
        End Sub


Here is the definition in my info file:

 Private _ModuleId As Integer
        Public Property ModuleId() As Integer
            Get
                Return _ModuleId
            End Get
            Set(ByVal value As Integer)
                _ModuleId = value
            End Set
        End Property

And finally here is my ObjectDataSource:

<asp:Label ID="lblModuleId" runat="server"></asp:Label>
<asp:ObjectDataSource ID="ObjectDataSource_QBirthdayToday"
    runat="server"
    DataObjectTypeName="Q.Modules.BirthdayToday.QBirthdayTodayInfo"
    SelectMethod="QBirthdayToday_Select"
    InsertMethod="QBirthdayToday_Insert"
    UpdateMethod="QBirthdayToday_Update"
    DeleteMethod="QBirthdayTodayInfo_Delete"
    OldValuesParameterFormatString="original_{0}"
    OnInit="Page_Load"
    TypeName="Q.Modules.BirthdayToday.QBirthdayTodayController">
    <SelectParameters>
        <asp:Parameter DefaultValue="00" Name="ModuleId" Type="Int32" />
    </SelectParameters>
    <DeleteParameters>
        <asp:Parameter Name="Original_ID" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="ModuleId" Type="Int32" />
        <asp:Parameter Name="Id" Type="Int32" />
        <asp:Parameter Name="IndividualFirstName" Type="String" />
        <asp:Parameter Name="IndividualLastName" Type="String" />
        <asp:Parameter Name="Individual" Type="String" />
        <asp:Parameter Name="Day" Type="Int32" />
        <asp:Parameter Name="Month" Type="Int32" />
        <asp:Parameter Name="Year" Type="Int32" />
        <asp:Parameter Name="IsLiving" Type="Int32" />
    </UpdateParameters>
    <InsertParameters>
        <asp:ControlParameter ControlID="lblModuleId" Name="ModuleId" PropertyName="Text" Type="Int16" />
        <asp:Parameter Name="IndividualFirstName" Type="String" />
        <asp:Parameter Name="IndividualLastName" Type="String" />
        <asp:Parameter Name="Individual" Type="String" />
        <asp:Parameter Name="Day" Type="Int32" />
        <asp:Parameter Name="Month" Type="Int32" />
        <asp:Parameter Name="Year" Type="Int32" />
        <asp:Parameter Name="IsLiving" Type="Int32" />
    </InsertParameters>
</asp:ObjectDataSource>

 

 
New Post
8/31/2007 3:30 PM
 

Where and how do you populate this property? BirthdayTodayInfo.ModuleId


Do you know the truth when you hear it?
Néstor Sánchez
The Dúnadan Raptor -->Follow Me on Twitter Now!
 
New Post
8/31/2007 3:59 PM
 

I Guess this is what you're asking for:

Protected Sub SetModuleID(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles ObjectDataSource_Tasks.Selecting
e.InputParameters("ModuleId") = ModuleId.ToString
End Sub

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ModuleId returns 0ModuleId returns 0


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out