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  |  

The best choice for your web site host, email hosting, and domain registration.
  Need Help?  
Professional technical support for DotNetNuke is available from DotNetNuke Corporation.
 


  Ads  
Iron Speed Designer is a software development tool for building database, reporting, and forms applications for .NET without hand-coding.
 


  Sponsors  

Meet Our Sponsors

CrystalTech Web Hosting™
Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
AspDotNetStoreFront - E-Commerce by Design - The Leading ASP.NET shopping cart platform for developers!
Click here to go to dev.live.com for Windows Live developer resources
SteadyRain
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  Deleting from a datalist using ObjectDataSource
Previous Previous
 
Next Next
New Post 3/26/2008 5:49 PM
User is offline Walkingpig
19 posts
10th Ranked


Deleting from a datalist using ObjectDataSource 

Hi all,

Sorry again in advance for what is assuredly a 'noob' question. I have as some would know, modified Michael washingtons Tradingpost example on building a module, however one of my modifications required a shift from a gridview with builtin delete etc to a datalist.

Thus far i have wired up a command button and a function, however my object datasource's delete funtion requires my class, and then executes my delete stored proceedure, passing the ID of the chosen ?entry? in my class. However, without the builtin gridview delete option firing off the right information automatically, i'm naturally stumped as to how to achieve this from the codebehind, as always - here is my code!:

I have highlighted in yellow the section i am assuming i need to work on, i have no idea how to make the delete() feed the right item, the commented line was a failed attempt based on some online articles. again many thanks for helping me out!

my Controller.cs:

[DataObjectMethod(DataObjectMethodType.Delete)]
public static void Fileman_Delete(FilemanInfo FilemanInfo)
{
DataProvider.Instance().ExecuteNonQuery("Fileman_Delete", FilemanInfo.ID);
}

------------------------------------------------------------------------------------------------

my codebehind function fired by clicking my "delete button" within an item of the datalist:

protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
string cmd = ((Button)e.CommandSource).CommandName;
int cma = System.Convert.ToInt16(e.CommandArgument);

if (cmd == "delete")
{
//ObjectDataSource_Fileman.DeleteParameters["DelID"].DefaultValue = cma.ToString();
ObjectDataSource_Fileman.Delete();

messagebox.Text = cmd + cma + "deletion was attempted... but why no delete AND no error";
}
}

------------------------------------------------------

chunk of my aspx representing part of the datalist itemtemplate:

<asp:DataList ID="DataList1" runat="server" DataSourceID="ObjectDataSource_Fileman" OnItemCommand="DataList1_ItemCommand" DataKeyField="ID">
<ItemTemplate>
<table>
<tr>
<td colspan="2">
<asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
</td>
</tr>
<tr>
<td rowspan="2">
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "./Pictures/" + Eval("Logo") %>' Width="110px" />
</td>
<td width="400">
<asp:Label ID="NotesLabel" runat="server" Text='<%# Eval("Notes") %>'></asp:Label></td>
</tr>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource_FilemanFiles" OnRowDataBound="HideEditButtons"
Visible="False" Width="100px">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="PDF_ID" HeaderText="PDF_ID" SortExpression="PDF_ID" />
<asp:BoundField DataField="File_title" HeaderText="File_title" SortExpression="File_title" >
<ItemStyle Width="290px" />
</asp:BoundField>
<asp:BoundField DataField="File_loc" HeaderText="File_loc" SortExpression="File_loc" >
<ItemStyle BackColor="#C0FFFF" BorderColor="#00C0C0" BorderStyle="Solid" BorderWidth="1px"
Font-Bold="True" Width="90px" />
</asp:BoundField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
<asp:Button ID="AddFileButton" runat="server" Text="Add File" CommandArgument='<%# Eval("ID") %>' CommandName="addfile" />
<asp:Button ID="DeleteBlockButton" runat="server" Text="Delete Block" CommandArgument='<%# Eval("ID") %>' CommandName="delete" /><br />
<hr />
</ItemTemplate>

 
New Post 3/26/2008 8:34 PM
User is offline Michael Washington
2750 posts
ADefWebserver.com
5th Ranked










Re: Deleting from a datalist using ObjectDataSource 
Modified By Michael Washington  on 3/26/2008 11:35:32 PM)

This should work:

 

FilemanInfo FilemanInfo = new FilemanInfo();
FilemanInfo.ID = cma.ToString(); 
ObjectDataSource_Fileman.Delete(FilemanInfo);



Michael Washington
* ADefWebserver.com
* DNN Module Developer's Guide
* IWEB - DNN Web Services
* Silverlight and DotNetNuke
 
New Post 3/26/2008 10:39 PM
User is offline Walkingpig
19 posts
10th Ranked


Re: Deleting from a datalist using ObjectDataSource 

Michael,

Thanks again for your advice - i tested what you said however i got an error building the website that ObjectDataSource_Fileman.Delete(Filemaninfo); has no overload that takes 1 variable. tried it () instead of (filemanInfo) and naturally nothing worked.

I am not sure how i would circumnavigate this issue, so i have cheated, and imported: using DotNetNuke.Data; to the top of the codebehind and copied the internals of the delete function in the controller.cs file... however this feels very naughty and negates the point of having that controller to a degree? :( Also i have to refresh the page a few times to actually have the datalist rebuild minus what i've deleted - but i'm sure i can figure that one out!

DataProvider

.Instance().ExecuteNonQuery("Fileman_Delete", cma);

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  Deleting from a datalist using ObjectDataSource
 


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.

 


Aricie
Aricie is one of the French pioneers and experts in DotNetNuke technology.
www.aricie.com
AFUEGO!
Looking for Free DNN Hosting?
www.AFUEGO.com
Code 5 Systems, LLC.
The DNN Missing Link: A Form Module. Form Master 1.6 is an intuitive Form Creation Module at a great price. Quality Custom Module development, and DNN consulting services.
www.code5systems.com

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