Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

Affordable ASP.NET Hosting Service
  Ads  
Engage Software - Training Partner for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

Merak Mail Server
WebSecureStores -- ASP.NET & DotNetNuke Hosting Solutions
FCKeditor Project
Salaro -- Skins and more
OnyakTech
CrystalTech Web Hosting™
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  GridView and ObjectDataSource problem in new module for DotNetNuke
Previous Previous
 
Next Next
New Post 4/20/2006 3:30 AM
User is offline Pål Fredrik Hasle
16 posts
10th Ranked


GridView and ObjectDataSource problem in new module for DotNetNuke 

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 9:21 AM
User is offline Michael Washington
2848 posts
ADefWebserver.com
5th Ranked










Re: GridView and ObjectDataSource problem in new module for DotNetNuke 
Modified By Michael Washington  on 4/20/2006 6:30:20 PM)

Try adding:

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



Michael Washington
* ADefWebserver.com
* DNN Module Developer's Guide
* IWEB - DNN Web Services
* Silverlight and DotNetNuke
 
New Post 4/27/2006 4:59 PM
User is offline Matticus Hardius
1 posts
10th Ranked


Re: GridView and ObjectDataSource problem in new module for DotNetNuke 

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 Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  GridView and ObjectDataSource problem in new module for DotNetNuke
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


PointClick DotNetNuke Solutions
PointClick Technologies provides high-end DNN Hosting for businesses.
PointClick.Net Hosted Solutions
Active Modules, Inc.
Creators of Active Forums, the best forum module for DotNetNuke
www.activemodules.com
DotNetNuke Marketplace - Modules & Skins
The DotNetNuke Marketplace is the official e-commerce gateway for the DNN ecosystem. It's the place to buy and sell DotNetNuke modules, DotNetNuke skins, and other DNN offerings.
DotNetNuke Marketplace

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP