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.0GridView and ObjectDataSource problem in new module for DotNetNukeGridView and ObjectDataSource problem in new module for DotNetNuke
Previous
 
Next
New Post
4/20/2006 5:30 AM
 

Hi!

I have a problem when trying to make a new module for DotNetNuke 4. What I am trying to do is to use a GridView, in a user control, and bind it to a datasource, ObjectDataSource. The GridView get’s data from the datasource. But when I try to do updates or deletes in the GridView it can’t take the values in the grid and send it to the delete method that is set in the ObjectDataSource. The delete method get’s a empty object.

Do someone know why this happens?

 

The code is mainly from the DotNetNuke StarterKit and a Guestbook example posted on the net.

Business Class:

    Public Class MemberlistController

        <DataObjectMethod(DataObjectMethodType.Delete)> _

        Public Shared Sub Memberlist_Delete(ByVal objTest As MemberlistInfo)

            DataProvider.Instance.Name_Memberlist_Delete(objTest.ID)

        End Sub               

        ..

    End Class

       

     

UserControl:

<%@ Control language="vb" Inherits="Name.Modules.Memberlist.ViewMemberlist" CodeFile="ViewMemberlist.ascx.vb" AutoEventWireup="false" Explicit="True" %>

<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>

 

<asp:ObjectDataSource

ID="ObjectDataSource_Tasks"

runat="server"

DeleteMethod="Memberlist_Delete"

InsertMethod="Memberlist_Insert" 

SelectMethod="Memberlist_GetAll"

UpdateMethod="Memberlist_Update"

DataObjectTypeName="Name.Modules.Memberlist.MemberlistInfo"

TypeName="Name.Modules.Memberlist.MemberlistController"

OnInit="Page_Load">

<SelectParameters>

<asp:Parameter DefaultValue="00" Name="ModuleId" Type="Int32" />

</SelectParameters>

</asp:ObjectDataSource>

 

<br />

<center><dnn:Label ID="lblAddMessage" Visible= "false" runat="server" ControlName="lblAddMessage" Suffix=":"></dnn:Label></center>

 

<asp:GridView

ID="GridView1"

runat="server"

DataSourceID="ObjectDataSource_Tasks" 

AutoGenerateColumns="false"

AutoGenerateDeleteButton="True"

AutoGenerateEditButton="True"

AllowPaging="True"

HorizontalAlign="Center"

style="left: 0px; position: relative; top: -118px"

Width="1056px"

ToolTip="Medlemslist"

CellPadding="3"

GridLines="None"

ForeColor="#333333">

<Columns>

<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />

<asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />

<asp:BoundField DataField="Address" HeaderText="Addresse" SortExpression="Address" />

<asp:BoundField DataField="Telephone" HeaderText="Telephone" SortExpression="Telephone" />

<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />

<asp:BoundField ApplyFormatInEditMode="true" DataField="DateEntered" DataFormatString="{0:d}"

HeaderText="Reg Dato" SortExpression="DateEntered" HtmlEncode="False" />

</Columns>

<EmptyDataTemplate>

No Enteries

</EmptyDataTemplate>

    <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />

    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />

    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />

    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />

    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />

    <EditRowStyle BackColor="#999999" Wrap="True" />

</asp:GridView>

 

 

 

 

 
New Post
4/20/2006 11:21 AM
 

Try adding:

<asp:BoundField DataField="ID" HeaderText="ID" Visible="False" />



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
4/27/2006 6:59 PM
 

Try adding DataKeyNames="ID" to the end of your gridview definition.

Ex:  

<asp:GridView

ID="GridView1"

runat="server"

DataSourceID="ObjectDataSource_Tasks" 

AutoGenerateColumns="false"

AutoGenerateDeleteButton="True"

AutoGenerateEditButton="True"

AllowPaging="True"

HorizontalAlign="Center"

style="left: 0px; position: relative; top: -118px"

Width="1056px"

ToolTip="Medlemslist"

CellPadding="3"

GridLines="None"

ForeColor="#333333"

DataKeyNames="ID">

 

 You might also need to add a column in the gridview with for the ID value, but mark it as false.

<asp:BoundField DataField="ID" HeaderText="ID" Visible="False" />

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0GridView and ObjectDataSource problem in new module for DotNetNukeGridView and ObjectDataSource problem in new module for DotNetNuke


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