API
Version 7.x > API > InfoDataSet<TypeInfo>.Items.Add() leaves empty DataSet View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 5/23/2013 1:27:00 AM
   
InfoDataSet<TypeInfo>.Items.Add() leaves empty DataSet
I have a InfoDataSet<MediaFileInfo> object I'm adding items to and all works great. Problem I'm having is when I return he InfoDataSet object an bind it to a MediaView control, the dataset is empty. I've debugged through the code and can see the Items being successfully added and that they are in the InfoDataSet<MediaFileInfo> object. But the actual dataset and tables are null or empty. How do I keep a strongly typed InfoDataSet<MediaFileInfo> object and return the values in the dataset?

Here is a small snippet of code:
MediaFileInfo mfi = MediaFileInfoProvider.GetMediaFileInfo(libraryId, currentFolder.TrimStart('\\'));

if (onlyGetNotImported && mfi == null)
{
MediaFileInfo mfiNew = new MediaFileInfo(string.Concat(rootFolder, currentFolder), libraryId, "");
mfiDataSet.Items.Add(mfiNew);
}

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 5/27/2013 6:00:37 AM
   
RE:InfoDataSet<TypeInfo>.Items.Add() leaves empty DataSet
Hi,

I am afraid but current version was not designed for this - so this approach won't work.

You need to either import the data to the DataSet as DataRow or,
use classic ASP.Net repeater and pass the Items collection directly to it.

Best regards,
Juraj Ondrus

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 5/27/2013 2:58:25 PM
   
RE:InfoDataSet<TypeInfo>.Items.Add() leaves empty DataSet
Well not the exact answer I was looking for but I guess I'll deal with it. Thanks for the help.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 5/28/2013 11:18:17 AM
   
RE:InfoDataSet<TypeInfo>.Items.Add() leaves empty DataSet
So is there a method to import an object to datarow or will I have to manually create my datarow based on the object? Seems like I should be able to call a method to convert a InfoDataSet<UserInfo>.Items to a DataRow. I'm taking a resultset, filtering records and modifying columns based on other records found, so I can't directly pass the Items collection to it.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/3/2013 7:27:57 AM
   
RE:InfoDataSet<TypeInfo>.Items.Add() leaves empty DataSet
Hi,

Unfortunately, there is no method for this - as far as I know. You need to create it manually - the object has the IDataContainer interface - so it should be possible to loop through each column name in a foreach.


Best regards,
Juraj Ondrus