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.0Deleting from a datalist using ObjectDataSourceDeleting from a datalist using ObjectDataSource
Previous
 
Next
New Post
3/26/2008 8:49 PM
 

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 11:34 PM
 

This should work:

 

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



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
3/27/2008 1:39 AM
 

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
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Deleting from a datalist using ObjectDataSourceDeleting from a datalist using ObjectDataSource


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