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>