How to send array of images to rdlc reports? - c#

I need to send a title and some images to a report, this is my class
public class ReportDataModel
{
public string Text { get; set; }
public IEnumerable<byte[]> Images { get; set; }
}
when i create a report file and set this class as the data source class and then in design i drag the image field on the report, on run time instead of images it shows "#Error".
thanks in advance.

Your current ReportDataModel uses a master-detail structure. It would not therefore be possible to drag drop images property to the report without showing "#Error", unless you are using an expression like First(Fields!Image.Value).
Change ReportDataModel to the following:
public class ReportDataModel
{
public string Text { get; set; }
public byte[] Image { get; set; }
}
Then instead of dragging the Image field directly on the report, drag an Image from the ToolBox, set image source to Database, select your image field and set MIME type.

Related

Export CSV - Kendo UI Grid with filters

There is out of the box support for exporting Kendo Grid data in Xlsx and Pdf formats, I'm looking for something similar for exporting in Csv format.
I have tried the server export described in: https://demos.telerik.com/aspnet-mvc/grid/server-export, which just sends the visible rows to the action; My unfiltered grid has over 250k entries. The output I'm looking for is the data in this table with the filters applied. I can get the data again in the same way the grid was populated and filter the data server-side, but how do we pass the selected filters to the action?
There appears to be a number of possible solutions, but I'm hoping to save time on going down a dead end. The documentation is often good with Kendo, but I'm struggling to find what I need with this one.
A possible solution is to get the filters applied on the Grid and send it to the server side and export the result as a expected format. To get the filter applied on the grid, you have to act over the dataSource.
var grid = $("#myGrid").data("kendoGrid");
var filter = grid.dataSource.filter();
Then, you have to send via jquery ajax, the filter.filters array to an action and bind it into a Type, maybe, something like this:
public class GridData
{
public GridFilter[] Filters { get; set; }
public string Logic { get; set; }
}
public class GridFilter
{
public string Operator { get; set; }
public string Field { get; set; }
public string Value { get; set; }
}
Then, get the data based on the GridData object and return provide the CSV information.

Data binding property in dev express grid designer not found

I have this class as you can see :
public class Document
{
public int Id { set; get; }
public string Number { set; get; }
public string Class { set; get; }
public string Discipline { set; get; }
public string Unit { set; get; }
public DateTime SubmitDateTime { set; get; }
}
It has a repository to get data from database ,in my form in UI in put a gridviewDevExpress so i pass my data using my repository to dev express gridview
private void frmDocument_Load(object sender, EventArgs e)
{
gridControlDocument.DataSource = _documentRepository.Get().ToList();
}
I want to bind my class to grid view,so i define my columns in gridview as you can see :
I want to bind my data base columns to grid view columns .I don't know where is the property ?
The result of my running is :
I have a record in database
There is a property on DevExpress gridview for columns that is called FieldName. So you can add database column name to FieldName.
You should either to create all the specific columns with the correctly assigned GridColumn.FieldName properties or do not create columns at all (in this case the GridControl will automatically populate columns itself).
For details, I suggest you use the following tutorial which describes the XtraGrid's design-time data binding specifics: Create and Manage Columns at Design Time.
Please, also read the following article that describes the data binding aspects related to columns: Creating Columns and Binding Them to Data Fields
Moreover, you can use the Data Source Configuration Wizard that allows you to choose the specific binding mode (direct, server-side, parallel or asynchronous) for various data sources (ADO, EF, SQL, Excel, WCF, XML, IEnumerable/IList and etc).

Store and export data from C# application

I'll try to explain this the best I can!
I've written a program that after some input, it brings 4 different text items into 4 separate ReadOnly text boxes. I'm looking to, when a user presses a button, it will store the strings from the 4 text boxes into a sort of table, so when the user then enters more data and it calculates a new set of 4 strings, when the press the button again, it will also store these values. The user should then be able to print this "table" style storage or export it into excel.
One approach could be -
You can create a class with properties to hold all the text boxes values. Something like this -
public class TextBoxesDetails
{
public string TextBox1Value { get; set; }
public string TextBox2Value { get; set; }
public string TextBox3Value { get; set; }
public string TextBoxValue4 { get; set; }
}
Next declare a global list variable of this type
List<TextBoxesDetails> TextBoxesDetails = new List<TextBoxesDetails>();
Now at the click of your button, store the values of all the text boxes into this list -
TextBoxesDetails.Add(new TextBoxesDetails {
TextBox1 = TextBox1Value.Text ,
TextBox2 = TextBox2Value.Text,
TextBox3 = TextBox3Value.Text,
TextBox4 = TextBox4Value.Text"
});
Now just use this list to export to excel.
For exporting to excel, I would suggest, https://npoi.codeplex.com/. The tool is also available through Nuget packages.

make a structure for generating custom form

I am developing a learning management system with asp.net c#
now i want to make a structure for generating university forms , but these forms may change in future or need new forms , i want make a structure for admin of website to generate custom forms without coding, admin only add the name of feilds and type of that ( its text box or checkbox and ... ) , then it should be a printable from , also admin can add explanation in diffrent part of the form...
i dont know how should i do this ?
is there any API or some idea ?
You could make some clases for your form controls like: InputBox, TextBox, CheckBox, RadioButton. Then a form class could contain lists of your input controls.
class FormInputControl
{
public string Description { get; set; } //Every form input has a description like User, link, what you want that form input control instance to describe
public abstract object Value { get; set; }
}
class InputBox : FormInputControl
{
public string Text { get; set; }
public overwrite object Value
{
get { return Text; }
set { Text = value as string; }
}
}
class Form
{
public IList<FormInputControls> { get; set; }
}

What control can display multicolumn data simply

I want to display data in one control Vertically with a window form control in C#, such as:
Title: The Game
Name: Andrew Smith
Age: 44
ISBN: 123456123456
Costs: £39.99
I'm looking for a simple display with code to add and remove items..
I have a list of data which I want to display quite simply from a list which will be displayed as Title/Item as above, which won't need to be amended only viewed.
Is there a way to find out the dimensions of the text and create padding, or is there an automatically adjusting multiple column type control? Any thing with some code to stop me going mad regarding special list Views and grid type views.
You can use DataGridView. It is simple to use.
You mentioned List Views in your post, and I think that is the answer for you. Try a ListView control with View set to Details. Use the Designer to create a column for each field in your data, and then use listView1.Items.Add() to add each item. (There is a constructor for ListViewItem which takes an array of strings; the strings are the values for each column.)
Create a BookItem class which has properties shown below.
public string Title { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public int ISBN { get; set; }
public string Cost { get; set; }
Generate a lstBookItems item List<> type and add BookItem items. But first, you must create bookItemInstance and fill data one by one.
List<BookItem> lstBookItems = new List<BookItem>();
lstBookItems.Add(bookItemInstance);
After this point, if you using ASP.Net
Create a Asp:ListView or Asp:GridView using Toolbox and give data source and bind data on code behind PageLoad() method
grdBooks.DataSource = lstBookItems;
grdBooks.DataBind();
And now, you can change appearence this gridView as you wish at Design screen(ex: vertical).

Categories