How to bind list objects inside Models in Xamarin - c#

I have the following problem, in which I'm trying to Data Bind a List inside a Model to my xaml file. I want to bind the list of IOSensors to the xaml file in some text labels.
Model:
class IOModule
{
public IOModule(string Name, string Type, string Version, string Location, string Desc)
{
this.Name = Name;
this.Type = Type;
this.Version = Version;
this.Serial = Location;
this.Status = Desc;
this.list = new List<IOSensor>();
}
public void addSensorInput(IOSensor sensor)
{
list.Add(sensor);
}
[JsonProperty("Name")]
public String Name { get; set; }
[JsonProperty("Type")]
public String Type { get; set; }
[JsonProperty("Version")]
public String Version { get; set; }
[JsonProperty("Serial")]
public String Serial { get; set; }
[JsonProperty("Status")]
public String Status { get; set; }
public List<IOSensor> list { get; }
public List<String> getIDs
{
get
{
List<string> list1 = new List<string>();
foreach (IOSensor sens in list)
{
list1.Add(sens.ID);
}
return list1;
}
}
}
public class IOSensor
{
public IOSensor(String ID, String Type, String GasComp, String MeasureType, String value)
{
this.ID = ID;
this.IOType = Type;
this.GasComp = GasComp;
this.MeasurementType = MeasureType;
this.Value = value;
}
[JsonProperty("ID")]
public String ID { get; set; }
[JsonProperty("IOType")]
public String IOType { get; set; }
[JsonProperty("GasComp")]
public String GasComp { get; set; }
[JsonProperty("MeasurementType")]
public String MeasurementType { get; set; }
[JsonProperty("Value")]
public String Value { get; set; }
}
ViewModel:
class IoModulesViewModels : BaseViewModel
{
public Item item;
public ObservableCollection<IOModule> modlists;
public IoModulesViewModels(Item item)
{
this.item = item;
this.modlists= new ObservableCollection<IOModule>();
//sendReq();
IOModule mod1 = new IOModule("1", "2", "3", "4", "5");
mod1.addSensorInput(new IOSensor("44", "55", "66", "77", "88"));
mod1.addSensorInput(new IOSensor("444", "545", "646", "747", "848"));
modlists.Add(mod1);
modlists.Add(mod1);
}
}
Xaml:
public partial class IoModulesPage : ContentPage
{
IoModulesViewModels ioModModels;
public IoModulesPage(Item item)
{
InitializeComponent();
BindingContext = this.ioModModels = new IoModulesViewModels(item);
Label header = new Label
{
Text = "ListView",
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
HorizontalOptions = LayoutOptions.Center
};
ListView lw = new ListView
{
ItemsSource = ioModModels.modlists,
HasUnevenRows = true,
ItemTemplate = new DataTemplate(() =>
{
var grid = new Grid();
Label modHeaderName = new Label();
modHeaderName.SetBinding(Label.TextProperty, "Name");
Label modHeaderType = new Label();
modHeaderType.SetBinding(Label.TextProperty, "Type");
Label modHeaderVersion = new Label();
modHeaderVersion.SetBinding(Label.TextProperty, "Version");
Label modHeaderSerial = new Label();
modHeaderSerial.SetBinding(Label.TextProperty, "Serial");
Label modHeaderStatus = new Label();
modHeaderStatus.SetBinding(Label.TextProperty, "Status");
grid.Children.Add(modHeaderName);
grid.Children.Add(modHeaderType, 1, 0);
grid.Children.Add(modHeaderVersion, 2, 0);
grid.Children.Add(modHeaderSerial, 3, 0);
grid.Children.Add(modHeaderStatus, 4, 0);
ListView lp = new ListView
{
ItemsSource = ioModModels.modlists,
HasUnevenRows = true,
ItemTemplate = new DataTemplate(() =>
{
Label header2 = new Label
{
Text = "ID,Type,GasComp,MeasurementType,Value",
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
HorizontalOptions = LayoutOptions.Fill
};
Grid gridIn = new Grid();
Label modID = new Label();
modID.SetBinding(Label.TextProperty, "getIDs");
Label modIOType = new Label();
modIOType.SetBinding(Label.TextProperty, "list.IOType");
Label modGasComp = new Label();
modGasComp.SetBinding(Label.TextProperty, "GasComp");
Label modMeasurementType = new Label();
modMeasurementType.SetBinding(Label.TextProperty, "list[0].MeasurementType");
Label modValue = new Label();
modValue.SetBinding(Label.TextProperty, "list[0].Value");
gridIn.Children.Add(modID);
gridIn.Children.Add(modIOType, 1, 0);
gridIn.Children.Add(modGasComp, 2, 0);
gridIn.Children.Add(modMeasurementType, 3, 0);
gridIn.Children.Add(modValue, 4, 0);
gridIn.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
gridIn.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
return new ViewCell
{
View = new StackLayout
{
Padding = new Thickness(0, 10),
Orientation = StackOrientation.Vertical,
Children =
{
header2,
gridIn
}
}
};
})
};
Frame frame = new Frame()
{
BorderColor=Color.Gray,
CornerRadius = 5,
Padding = 8,
Content = new StackLayout
{
Orientation=StackOrientation.Horizontal,
Children =
{
grid,
lp
}
}
};
return new ViewCell
{
View = new StackLayout
{
Padding = new Thickness(0, 10),
Spacing = 2,
Orientation = StackOrientation.Horizontal,
Children =
{
frame
}
}
};
}
)
};
// Accomodate iPhone status bar.
this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
// Build the page.
this.Content = new StackLayout
{
Children =
{
header,
lw
}
};
}
}
As you can see in the xaml file, I ve been trying many apporaches in which i can bind the list of IOSensors, but so far no luck. The Page is loading and showing some results (for example the Syntax with "list[0].property" works but i want it to work for every entry of the list.
Thanks ina dvance

As Jason said that you want to display a nested list of data, so I suggest you can use ListView Group to display data.
I modify your code, and creating one sample, that you can take a look:
Two models:
public class IOModule:List<IOSensor>
{
[JsonProperty("Name")]
public String Name { get; set; }
[JsonProperty("Type")]
public String Type { get; set; }
[JsonProperty("Version")]
public String Version { get; set; }
[JsonProperty("Serial")]
public String Serial { get; set; }
[JsonProperty("Status")]
public String Status { get; set; }
public List<IOSensor> list => this;
}
public class IOSensor
{
[JsonProperty("ID")]
public String ID { get; set; }
[JsonProperty("IOType")]
public String IOType { get; set; }
[JsonProperty("GasComp")]
public String GasComp { get; set; }
[JsonProperty("MeasurementType")]
public String MeasurementType { get; set; }
[JsonProperty("Value")]
public String Value { get; set; }
}
public partial class Page8 : ContentPage
{
public ObservableCollection<IOModule> modlists { get; set; }
public Page8()
{
InitializeComponent();
modlists = new ObservableCollection<IOModule>();
IOModule mod1 = new IOModule()
{
new IOSensor(){ID="IOSensor 1",IOType="",GasComp="",MeasurementType="",Value=""},
new IOSensor(){ID="IOSensor 2",IOType="",GasComp="",MeasurementType="",Value=""}
};
mod1.Name = "IOModule 1";
modlists.Add(mod1);
IOModule mod2 = new IOModule()
{
new IOSensor(){ID="IOSensor 3",IOType="",GasComp="",MeasurementType="",Value=""},
new IOSensor(){ID="IOSensor 4",IOType="",GasComp="",MeasurementType="",Value=""}
};
mod2.Name = "IOModule 2";
modlists.Add(mod2);
IOModule mod3 = new IOModule()
{
new IOSensor(){ID="IOSensor 5",IOType="",GasComp="",MeasurementType="",Value=""},
new IOSensor(){ID="IOSensor 6",IOType="",GasComp="",MeasurementType="",Value=""}
};
mod3.Name = "IOModule 3";
modlists.Add(mod3);
//this.BindingContext = this;
Label header = new Label
{
Text = "ListView",
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
HorizontalOptions = LayoutOptions.Center
};
ListView lw = new ListView();
lw.ItemsSource = modlists;
lw.IsGroupingEnabled = true;
lw.ItemTemplate = new DataTemplate(() =>
{
var grid = new Grid();
Label modHeaderName = new Label();
modHeaderName.SetBinding(Label.TextProperty, "ID");
Label modHeaderType = new Label();
modHeaderType.SetBinding(Label.TextProperty, "IOType");
Label modHeaderVersion = new Label();
modHeaderVersion.SetBinding(Label.TextProperty, "GasComp");
Label modHeaderSerial = new Label();
modHeaderSerial.SetBinding(Label.TextProperty, "MeasurementType");
Label modHeaderStatus = new Label();
modHeaderStatus.SetBinding(Label.TextProperty, "Value");
grid.Children.Add(modHeaderName);
grid.Children.Add(modHeaderType, 1, 0);
grid.Children.Add(modHeaderVersion, 2, 0);
grid.Children.Add(modHeaderSerial, 3, 0);
grid.Children.Add(modHeaderStatus, 4, 0);
return new ViewCell { View = grid };
});
lw.GroupHeaderTemplate = new DataTemplate(() =>
{
var grid = new Grid();
Label modHeaderName = new Label() {
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
FontAttributes = FontAttributes.Bold,
};
modHeaderName.SetBinding(Label.TextProperty, "Name");
//Label modHeaderType = new Label();
//modHeaderType.SetBinding(Label.TextProperty, "Type");
//Label modHeaderVersion = new Label();
//modHeaderVersion.SetBinding(Label.TextProperty, "Version");
//Label modHeaderSerial = new Label();
//modHeaderSerial.SetBinding(Label.TextProperty, "Serial");
//Label modHeaderStatus = new Label();
//modHeaderStatus.SetBinding(Label.TextProperty, "Status");
grid.Children.Add(modHeaderName);
//grid.Children.Add(modHeaderType, 1, 0);
//grid.Children.Add(modHeaderVersion, 2, 0);
//grid.Children.Add(modHeaderSerial, 3, 0);
//grid.Children.Add(modHeaderStatus, 4, 0);
return new ViewCell { View = grid };
});
this.Content = new StackLayout
{
Children =
{
header,
lw
}
};
}
}
This is screenshot;

Related

Why do I get the error: " Specified Cast is not valid" when trying to populate my listview in xamarin.forms with a list in my viewModel?

This is the code behind of the main page in my xamarin app
public partial class MainPage : ContentPage
{
PenStockVM<PenStock> penstocks;
public MainPage()
{
InitializeComponent();
penstocks = new PenStockVM<PenStock>();
//I get the error at this point saying that this cast is invalid. How to fix this?
listView.ItemsSource = (System.Collections.IEnumerable)penstocks;
BindingContext = penstocks;
}
}
This is my Penstock ViewModel class:
class PenStockVM<Penstock>
{
public List<PenStock>PenStocks { get; set; }
public PenStockVM()
{
PenStocks = new List<PenStock>();
FillPenStockData();
}
private ObservableCollection<Graph> FillGraphData()
{
ObservableCollection<Graph> entries = new ObservableCollection<Graph>();
Random random = new Random();
for (int i = 0; i < 10; i++)
{
entries.Add(new Graph { Time = i, Units = random.Next(100) });
}
return entries;
}
private void FillPenStockData()
{
PenStock object1 = new PenStock { Id = 1, Name = "Main PenStock", Data =
FillGraphData(), Rotations = 100 };
PenStocks.Add(object1);
PenStock object2 = new PenStock { Id = 2, Name = "Weir", Data = FillGraphData(),
Rotations = 100 };
PenStocks.Add(object2);
PenStock object3 = new PenStock { Id = 3, Name = "Spillway", Data = FillGraphData(),
Rotations = 100 };
PenStocks.Add(object3);
PenStock object4 = new PenStock { Id = 4, Name = "Sub PenStock 1", Data =
FillGraphData(), Rotations = 100 };
PenStocks.Add(object4);
PenStock object5 = new PenStock { Id = 5, Name = "Sub PenStock 2", Data =
FillGraphData(), Rotations = 100 };
PenStocks.Add(object5);
PenStock object6 = new PenStock { Id = 6, Name = "Sub PenStock 3", Data =
FillGraphData(), Rotations = 100 };
PenStocks.Add(object6);
}
}
This is my PenStock model class:
public class PenStock
{
public int Id { get; set; }
public string Name { get; set; }
public ObservableCollection<Graph> Data { get; set; }
public int Rotations { get; set; }
}
This is my other Graph model class:
public class Graph: INotifyPropertyChanged
{
private int time;
private int units;
public event PropertyChangedEventHandler PropertyChanged;
public int Time
{
get { return time; }
set
{
time = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Time"));
}
}
public int Units
{
get { return units; }
set
{
units = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Time"));
}
}
}
Do I get this error because I am trying to cast a generic list and the listView only accepts non-generic collections as item source? I am new to xamarin and please help me! Thank you.
I would set ItemsSource to PenStockVM.PenStocks. ItemsSource property specifies the items to display, which are defined in a list. A ListView is populated with data using the ItemsSource property, which is of type IEnumerable.
listView.ItemsSource = penstocks.PenStocks;

Binding MVVM XamarinForms

I have a class where I declare my 'Entry' and put Binding in its Text , I want the bindingContext to be stored in another class that I have.
But something is going wrong, I do not receive the information in the second class
I'm trying to do it like below
BindingContext = new TelaDados();
Label lblNome = new Label()
{
Text = "Digite seu Nome:"
};
Entry enNome = new Entry() { }
enNome.SetBinding(Entry.TextProperty,"Nome");
private void GoPaginaDados()
{
BindingContext = new TelaDados(); ////<---- HERE
DisplayAlert("ok", enNome.Text, "Ok");
Navigation.PushAsync(new TelaDados());
}
here below I try to get the information of the first class
lblNome.SetBinding(Label.TextProperty, "Nome");
the second class would be like this
public string Nome { get; set; }
public string Idade { get; set; }
public string Estado { get; set; }
public TelaDados()
{
Label lblNome = new Label()
{
TextColor = Color.Blue,
BackgroundColor = Color.Green
};
lblNome.SetBinding(Label.TextProperty, "Nome");
BindingContext = this;
}

Custom control c# for mark-up aligning controls to others

How Would I center my labels and my text boxes I want them like the uwp date time picker.
public class DateTimePicker2: ContentView, INotifyPropertyChanged
{
public Entry _entry { get; private set; } = new Entry()
{
WidthRequest = 300
};
public Entry _dayEntry { get; private set; } = new Entry()
{
Placeholder = "00", WidthRequest = 30
};
public Entry _monthEntry { get; private set; } = new Entry()
{
Placeholder = "00", WidthRequest = 30
};
public Entry _yearEntry { get; private set; } = new Entry()
{
Placeholder = "00", WidthRequest = 30
};
public Entry _hourEntry { get; private set; } = new Entry()
{
Placeholder = "00", WidthRequest = 30
};
public Entry _minsEntry {get;private set; } = new Entry()
{
Placeholder = "00", WidthRequest = 30
};
private static DateTime ? _defaultDateTime = DateTime.Now;
public DatePicker _datePicker { get; private set; } = new DatePicker()
{
MinimumDate = DateTime.Today, IsVisible = false
};
public TimePicker _timePicker { get; private set; } = new TimePicker()
{
IsVisible = false
};
public Label _dayLabel { get; private set; } = new Label()
{
Text = "DAY"
};
public Label _monthLabel { get; private set; } = new Label()
{
Text = "MONTH"
};
public Label _yearLabel { get; private set; } = new Label()
{
Text = "Year"
};
public Label _hourLabel { get; private set; } = new Label()
{
Text = "Hour"
};
public Label _minLabel { get; private set; } = new Label()
{
Text = "Min"
};
public Picker _ampmPicker { get; private set; } = new Picker()
{
ItemsSource = new List < string > { "AM", "PM" }
};
public Picker _twntyFourHourPicker { get; private set; } = new Picker()
{
ItemsSource = new List < string > { "12", "24" }
};
public DateTimePicker2()
{
BindingContext = this;
Content = new Frame()
{
BorderColor = Color.Black,
CornerRadius = 30,
Padding = new Thickness(10, 10, 10, 10),
Margin = new Thickness(20),
Content = new StackLayout
{
Orientation = StackOrientation.Horizontal,
Children =
{
_dayLabel,
_dayEntry,
_monthLabel,
_monthEntry,
_yearLabel,
_yearEntry,
_hourLabel,
_hourEntry,
_minLabel,
_minsEntry,
}
}
};
}
}
Basically, at present it its showing as such I want the rounded corners only to be the width of the controls and the Labels to be cantered above the text boxes is that possible if it means making text boxes bigger am ok with that, but as long as the text is centered.
By the way, am using c# for mark-up to render the controls.
Using Xamarin.Forms Grid can make the data more regular.
For more information, please refer to https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/grid
I wrote a small example for your referenceļ¼š
Here is background code:
Grid grid = new Grid
{
RowDefinitions =
{
new RowDefinition { Height = 25 },
new RowDefinition { Height = 50 },
},
ColumnDefinitions =
{
new ColumnDefinition { Width = 65 },
new ColumnDefinition { Width = 65 },
new ColumnDefinition { Width = 65 },
new ColumnDefinition { Width = 65 },
new ColumnDefinition { Width = 65 }
}
};
grid.Children.Add(new Label { Text = "Day" }, 0, 0);
grid.Children.Add(new Label { Text = "Month" }, 1, 0);
grid.Children.Add(new Label { Text = "Year" }, 2, 0);
grid.Children.Add(new Label { Text = "Hour" }, 3, 0);
grid.Children.Add(new Label { Text = "Min" }, 4, 0);
grid.Children.Add(new Entry { Placeholder = "00" }, 0, 1);
grid.Children.Add(new Entry { Placeholder = "00" }, 1, 1);
grid.Children.Add(new Entry { Placeholder = "00" }, 2, 1);
grid.Children.Add(new Entry { Placeholder = "00" }, 3, 1);
grid.Children.Add(new Entry { Placeholder = "00" }, 4, 1);
StackLayout stackLayout = new StackLayout
{
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children =
{
grid
}
};
Frame defaultFrame = new Frame
{
Content = stackLayout,
CornerRadius = 30,
Margin = new Thickness(20,20,20,20)
};
Content = new StackLayout
{
Children =
{
defaultFrame
}
};

How to covert this to for loop array c#.net

I am trying to create a dynamic control based in MVC,
I got a solution to implement.. it working fine..
with this code
public class DynamicControlViewModel
{
public ControlViewModel[] Controls { get; set; }
}
public abstract class ControlViewModel
{
public abstract string Type { get; }
public bool Visible { get; set; }
public string Label { get; set; }
public string Name { get; set; }
}
public class TextBoxViewModel : ControlViewModel
{
public override string Type
{
get { return "textbox"; }
}
public string Value { get; set; }
}
public class CheckBoxViewModel : ControlViewModel
{
public override string Type
{
get { return "checkbox"; }
}
public bool Value { get; set; }
}
public class DropDownListViewModel : TextBoxViewModel
{
public override string Type
{
get { return "ddl"; }
}
public SelectList Values { get; set; }
}
This is the way i am calling the object
public ActionResult Index()
{
return View(GetControls1());
}
public DynamicControlViewModel GetControls1()
{
var model1 = new DynamicControlViewModel
{
Controls = new ControlViewModel[] {
new DropDownListViewModel{Visible = true,Label = "drop label",Name = "DropDown1",Values = new SelectList(new[]{new { Value = "1", Text = "text 1" },new { Value = "2", Text = "text 2" },new { Value = "3", Text = "text 3" },}, "Value", "Text", "2")},
new TextBoxViewModel { Visible = true, Label = "label 1", Name = "TextBox1", Value = "value of textbox" },
new CheckBoxViewModel { Visible = true, Label = "CheckBox label 1", Name = "CheckBox1", Value = true},
new TextBoxViewModel { Visible = true, Label = "label 2", Name = "TextBox2", Value = "value of textbox" }}
};
return model1;
}
Here,
I need to use for loop to create the dynamic control..
here is my code, getting error
public DynamicControlViewModel GetControls()
{
var model = new DynamicControlViewModel { };
var Controls1 = new ControlViewModel[] { };
var s = model.Controls;
//int i=0;
//for loop start
Controls1[0] = new TextBoxViewModel { Visible = true, Label = "label 2", Name = "TextBox2", Value = "value of textbox" };
Controls1[1] = new TextBoxViewModel { Visible = true, Label = "label 3", Name = "TextBox3", Value = "value of textbox" };
Controls1[2] = new CheckBoxViewModel { Visible = true, Label = "CheckBox label 1", Name = "CheckBox1", Value = true },
Controls1[3] = new DropDownListViewModel { Visible = true, Label = "drop label", Name = "DropDown1", Values = new SelectList(new[] { new { Value = "1", Text = "text 1" }, new { Value = "2", Text = "text 2" }, new { Value = "3", Text = "text 3" }, }, "Value", "Text", "2") },
//loop end
var model1 = new DynamicControlViewModel
{
Controls = Controls1
};
return model1;
}
The problem is that you first define an array of size 0 (i.e. with 0 cells to hold values):
var Controls1 = new ControlViewModel[] { }; // array with length 0
Afterwards you try to assign to the first, second, third and fourth cell of the array, which do not exist. Therefore you get the error.
So you should either use a List<ControlViewModel> or initialize an array of the correct length:
var Controls1 = new ControlViewModel[4];

Telerik WinForms RadGridView create and fill in runtime

My question is pretty similar for this
Fill RadGridView dynamically
but i dont want to create datatable
This is grid view
GridView = new RadGridView
{
AutoSizeRows = true,
BeginEditMode = RadGridViewBeginEditMode.BeginEditProgrammatically,
Location = new Point(0, 130),
Name = "GridView",
ShowRowErrors = false,
Size = new Size(390, 100),
TabIndex = 0,
Visible = false
};
This method creates columns in runtime
private List<GridViewTextBoxColumn> InitializeColumns()
{
var result = new List<GridViewTextBoxColumn>();
{
var columnId = new GridViewTextBoxColumn
{
Name = "RecordID",
HeaderText = "ID",
FieldName = "RecordID",
MaxLength = 50,
Width = 50,
DataType = typeof(int)
};
result.Add(columnId);
}
{
var columnInformation = new GridViewTextBoxColumn
{
Name = "RecordInformation",
HeaderText = "Information",
FieldName = "RecordInformation",
MaxLength = 50,
Width = 250,
DataType = typeof(string)
};
result.Add(columnInformation);
}
{
var columnRowType = new GridViewTextBoxColumn
{
Name = "RecordType",
HeaderText = "Type",
FieldName = "RecordType",
MaxLength = 50,
Width = 250,
DataType = typeof(string)
};
result.Add(columnRowType);
}
return result;
}
This class is for grid row
internal class OrderTripChangedAlertItem
{
public int RecordID { get; set; }
public string RecordInformation { get; set; }
public string RecordType { get; set; }
public OrderTripChangedAlertItem(int recordID, string recordInformation, string recordType)
{
RecordID = recordID;
RecordInformation = recordInformation;
RecordType = recordType;
}
}
So i bind the List to grid view. Columns are displayed fine, but not data shown. There must be one record. What i missed ?
Here is the whole code I placed on a Form and this works just fine:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
RadGridView GridView = new RadGridView
{
AutoSizeRows = true,
BeginEditMode = RadGridViewBeginEditMode.BeginEditProgrammatically,
Location = new Point(0, 130),
Name = "GridView",
ShowRowErrors = false,
Size = new Size(390, 100),
TabIndex = 0,
//Visible = false,
Parent = this
};
GridView.Columns.AddRange(InitializeColumns().ToArray());
List<OrderTripChangedAlertItem> list = new List<OrderTripChangedAlertItem>();
OrderTripChangedAlertItem item = new OrderTripChangedAlertItem(0, "some info", "some type");
list.Add(item);
GridView.DataSource = list;
}
private List<GridViewTextBoxColumn> InitializeColumns()
{
var result = new List<GridViewTextBoxColumn>();
{
var columnId = new GridViewTextBoxColumn
{
Name = "RecordID",
HeaderText = "ID",
FieldName = "RecordID",
MaxLength = 50,
Width = 50,
DataType = typeof(int)
};
result.Add(columnId);
}
{
var columnInformation = new GridViewTextBoxColumn
{
Name = "RecordInformation",
HeaderText = "Information",
FieldName = "RecordInformation",
MaxLength = 50,
Width = 250,
DataType = typeof(string)
};
result.Add(columnInformation);
}
{
var columnRowType = new GridViewTextBoxColumn
{
Name = "RecordType",
HeaderText = "Type",
FieldName = "RecordType",
MaxLength = 50,
Width = 250,
DataType = typeof(string)
};
result.Add(columnRowType);
}
return result;
}
internal class OrderTripChangedAlertItem
{
public int RecordID { get; set; }
public string RecordInformation { get; set; }
public string RecordType { get; set; }
public OrderTripChangedAlertItem(int recordID, string recordInformation, string recordType)
{
RecordID = recordID;
RecordInformation = recordInformation;
RecordType = recordType;
}
}

Categories

Resources