Why SelectOnRowClick doesn't disable toggling the checkbox state on row-click? - c#

I'm using MudBlazor v.6.1.5 and trying to create table with "row selection on click" property blocked the same way as in MudBlazor docs (https://mudblazor.com/components/table#multi-selection)
For some reason propety "SelectOnRowClick" doesn't disable toggling the checkbox state for tables in my project. Here is simple code snippet:
#page "/test"
<MudSwitch #bind-Checked="#_selectOnRowClick">SelectOnRowClick: #_selectOnRowClick</MudSwitch>
<MudText Inline="true">Item: #_selectedItemText</MudText>
<MudText>Selected items (#selectedItems?.Count): #(selectedItems == null ? "" : string.Join(", ", selectedItems.OrderBy(x => x.Sign).Select(x => x.Sign)))</MudText>
<MudTable #ref="_table" T="Element" Items="#Elements" MultiSelection="true" #bind-SelectedItems="selectedItems" Hover="true"
OnRowClick="#OnRowClick" #bind-SelectOnRowClick="#_selectOnRowClick">
<HeaderContent>
<MudTh>Nr</MudTh>
<MudTh>Sign</MudTh>
<MudTh>Name</MudTh>
<MudTh>Position</MudTh>
<MudTh>Molar mass</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Nr">#context.Number</MudTd>
<MudTd DataLabel="Sign">#context.Sign</MudTd>
<MudTd DataLabel="Name">#context.Name</MudTd>
<MudTd DataLabel="Position">#context.Position</MudTd>
<MudTd DataLabel="Molar mass">#context.Molar</MudTd>
</RowTemplate>
<PagerContent>
<MudTablePager PageSizeOptions="new int[]{50, 100}" />
</PagerContent>
<FooterContent>
<MudTd colspan="5">Select All</MudTd>
</FooterContent>
</MudTable>
#code {
private HashSet<Element> selectedItems = new HashSet<Element>();
private IEnumerable<Element> Elements = new List<Element>();
private bool _selectOnRowClick = true;
private MudTable<Element> _table;
private string _selectedItemText = "No row clicked";
protected override async Task OnInitializedAsync()
{
Elements = new List<Element>()
{
new Element(){Name="Hydrogen", Sign="H", Position=0, Molar = 1.00794},
new Element(){Name="Hydrogen", Sign="H", Position=0, Molar = 1.00794},
new Element(){Name="Hydrogen", Sign="H", Position=0, Molar = 1.00794},
new Element(){Name="Hydrogen", Sign="H", Position=0, Molar = 1.00794},
new Element(){Name="Hydrogen", Sign="H", Position=0, Molar = 1.00794},
new Element(){Name="Hydrogen", Sign="H", Position=0, Molar = 1.00794}
};
}
void OnRowClick(TableRowClickEventArgs<Element> args)
{
_selectedItemText = $"{args.Item.Name} ({args.Item.Sign})";
}
public class Element
{
public string Group { get; set; }
public int Position { get; set; }
public string Name { get; set; }
public int Number { get; set; }
public string Sign { get; set; }
public double Molar { get; set; }
public IList<int> Electrons { get; set; }
public override string ToString()
{
return $"{Sign} - {Name}";
}
}
}
The same code in MudBlazor playground works fine, am I missing something?

The problem was solved by updating MudBlazor to v6.1.9.

Related

Unrealistically Annoying 'Invalid Data Type in Criteria Expression'

I have the following query
public const string UpdateSample =
#"UPDATE subReceivingQC
SET Clerk=#Clerk, Comments=#Comments, CommentsProd=#CommentsProd, MassOff=#MassOff,
PalletID=#PalletID, QCDate=#QCDate, QtyInspected=#QtyInspected, StatusClerk=#StatusClerk,
StatusSupervisor=#StatusSupervisor, Supervisor=#Supervisor, PackOut=#PackOut
WHERE GRV=#GRV AND PalletSeq=#PalletSeq AND SampleNo=#SampleNo";
And inserting the item with this code
// Update sample
query = DatabaseConstants.UpdateSample;
args = new DynamicParameters();
args.Add("#Clerk", sample.Clerk, DbType.String);
args.Add("#Comments", sample.Comments, DbType.String);
args.Add("#CommentsProd", sample.CommentsProd, DbType.String);
args.Add("#MassOff", sample.MassOff, DbType.String);
args.Add("#PackOut", sample.PackOut, DbType.String);
args.Add("#PalletID", sample.PalletID, DbType.String);
args.Add("#QCDate", sample.QCDate, DbType.Date);
args.Add("#QtyInspected ", sample.QtyInspected, DbType.Decimal);
args.Add("#StatusClerk", sample.StatusClerk, DbType.String);
args.Add("#StatusSupervisor", sample.StatusSupervisor, DbType.String);
args.Add("#Supervisor", sample.Supervisor, DbType.String);
args.Add("#GRV", sample.GRV, DbType.Int64);
args.Add("#PalletSeq", sample.PalletSeq, DbType.Int16);
args.Add("#SampleNo", sample.SampleNo, DbType.Int16);
using (var db = new OleDbConnection(connectionString))
{
output += db.Execute(query, args);
}
Now MassOff and PackOut are both of type double, where the Access data type looks like this for both:
The weird thing here is that the code works perfectly for the property MassOff, but after adding the line for PackOut I get
Invalid Data Type in Criteria Expression
I tried changing the parameter DbType.Decimal and DbType.Double but it makes no difference.
None of the parameters in my query are in the same order as they appear in the db, so I don't think that is the cause as then I would be seeing the same issue without the PackOut value.
For instance, when I try passing in these values:
MassOff : 9.5
PackOut : 70.5
It works for MassOff but not PackOut
How in God's name is this possible?
Sample class
public class Sample :
QCObject, IGriddable
{
private string imagesPath = ConfigurationManager.AppSettings["ImagesPath"];
private string[] columnHeaders;
public string[] ColumnHeaders {
get
{
if(columnHeaders.IsNullOrEmpty())
{
return new string[] { "SampleNo", "Date", /*"QCDate",*/ "StatusClerk", "StatusSupervisor" };
}
else
{
return columnHeaders;
}
}
set { columnHeaders = value; } }
private string rowLinkPrefix;
public string RowLinkPrefix {
get
{
if(string.IsNullOrWhiteSpace(rowLinkPrefix))
{
return $"/receiving/{GRV}/{Pallet.PalletSeq}/";
}
else
{
return rowLinkPrefix;
}
}
set { rowLinkPrefix = value; } }
public bool Selectable { get; } = true;
public Pallet Pallet { get; set; }
// Should be 100 - (massoff/qtinspected) but building this manually
// at the moment due to lack of data integrity
[DisplayName("Pack Out")]
public double PackOut { get; set; }
[DisplayName("Pack Out Percentage")]
public double PackoutPerc { get; set; }
[DisplayName("Percentage")]
public double Perc { get; set; }
[DisplayName("Mass Off")]
public double MassOff { get; set; }
[DisplayName("Production Comments")]
public string CommentsProd { get; set; }
[DisplayName("Technical Comments")]
public string Comments { get; set; }
[DisplayName("Quantity Inspected")]
public double QtyInspected { get; set; }
[DisplayName("Sample Number")]
public int SampleNo { get; set; }
[DisplayName("Status Clerk")]
public string StatusClerk { get; set; }
[DisplayName("Status Supervisor")]
public string StatusSupervisor { get; set; }
[DisplayName("Product Spec")]
public string ProductSpec { get; set; }
[DisplayName("PO Container")]
public string POContainer { get; set; }
public string Supervisor { get; set; }
public string Clerk { get; set; }
// For required db params
public string GRV { get; set; }
public string PalletID { get; set; }
[DisplayName("Pallet")]
public string PalletSeq { get; set; }
[DisplayName("Date")]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime QCDate { get; set; }
public string Date { get { return QCDate.ToString("dd/MM/yyyy"); } } // My generic WebGrid solution does not alllow me to change thed ate formats, so use this instead
// Each defect status needs to be saved as a (DB)subQCItems item
public List<QCItem> Defects { get; set; } = new List<QCItem>();
public IEnumerable<string> Users { get; set; } = new List<string>();
public Sample()
{
var access = new Access();
Users = access.GetUsers();
}
public IEnumerable<string> Images
{
get
{
string physicalDir;
var dir = Path.Combine(imagesPath, $#"{Pallet.Grv.GRVNo}\{Pallet.PalletSeq}\{SampleNo}\");
physicalDir = dir;
if (Path.IsPathRooted(dir))
{
physicalDir = dir;
}
else
{
physicalDir = HttpContext.Current.Server.MapPath(dir);
}
if (!Directory.Exists(physicalDir))
Directory.CreateDirectory(physicalDir);
foreach (var filePath in Directory.GetFiles(physicalDir).Where(f => f != null))
{
yield return Path.Combine(dir, Path.GetFileName(filePath));
}
}
}
public void SaveImages(IEnumerable<HttpPostedFileBase> files)
{
foreach (var file in files.Where(f => f != null))
{
var dir = $#"{imagesPath}/{Pallet.Grv.GRVNo}/{Pallet.PalletSeq}/{SampleNo}";
var physicalDir = HttpContext.Current.Server.MapPath(dir);
var imageDirInfo = Directory.CreateDirectory(physicalDir);
var counter = imageDirInfo.EnumerateFiles().Count() + 1;
var path = Path.Combine($#"{physicalDir}", $"{counter}{Path.GetExtension(file.FileName)}");
file.SaveAs(path);
counter++;
}
}
}
OLEDB ignores parameter names. args.Add the parameters in the same order they appear in the UPDATE statement
args.Add("#Clerk", sample.Clerk, DbType.String);
args.Add("#Comments", sample.Comments, DbType.String);
args.Add("#CommentsProd", sample.CommentsProd, DbType.String);
args.Add("#MassOff", sample.MassOff, DbType.String);
args.Add("#PalletID", sample.PalletID, DbType.String);
args.Add("#QCDate", sample.QCDate, DbType.Date);
args.Add("#QtyInspected ", sample.QtyInspected, DbType.Decimal);
args.Add("#StatusClerk", sample.StatusClerk, DbType.String);
args.Add("#StatusSupervisor", sample.StatusSupervisor, DbType.String);
args.Add("#Supervisor", sample.Supervisor, DbType.String);
args.Add("#PackOut", sample.PackOut, DbType.String);
args.Add("#GRV", sample.GRV, DbType.Int64);
args.Add("#PalletSeq", sample.PalletSeq, DbType.Int16);
args.Add("#SampleNo", sample.SampleNo, DbType.Int16);

How to get a list of items include in a class from Entity Framework database

I have a problem with my application. I cannot get from the database a object where there's a list in it. I'm really not good in Entity Framework so sorry if this is a really big mistake.
public List<Recipe> GetRecipes(Cook cook)
{
List<Recipe> L_Recipes = new List<Recipe>();
Cook Cook = dbc.DbCook.SingleOrDefault(c => c.Nickname == cook.Nickname);
L_Recipes = Cook.ListRecipes;
return L_Recipes;
}
and this is the Recipe class:
public class Recipe
{
//Attributes
public int Id { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public float CostPrice { get; set; }
public float SellingPrice { get; set; }
public DateTime Date { get; set; }
public List<Ingredient> ListIngredients { get; set; }
public List<Comment> ListComments { get; set; }
public Schedule Schedules { get; set; }
//Builder
public Recipe(string name, string type)
{
Name = name;
Type = type;
Date = DateTime.Now;
ListIngredients = new List<Ingredient>();
Schedules = new Schedule();
}
public Recipe(string name,string type,float costPrice,float SellingPrice,DateTime Date,List<Ingredient> ListIngredients,List<Comment> ListComments,Schedule Schedules)
{
this.Name = name;
this.Type = type;
this.CostPrice = costPrice;
this.SellingPrice = SellingPrice;
this.Date = Date;
this.ListIngredients = ListIngredients;
this.ListComments = ListComments;
this.Schedules = Schedules;
}
public Recipe() { ListIngredients = new List<Ingredient>(); }
//Methods
public void AddIngredient(Ingredient i)
{
ListIngredients.Add(i);
}
public float CalculCostPrice()
{
float cost = 0;
foreach (Ingredient ing in ListIngredients)
{
cost += ing.CalculCostIngredient();
}
return cost;
}
public float CalculSellingPrice()
{
return (float)(CalculCostPrice()*1.05);
}
public override string ToString()
{
string SP = string.Format("{0:00.00}", SellingPrice);
return $"{Name} for {SP} euros added the {Date.ToString()}";
}
}
The problem is I received the info of the recipe but not the list in it.
It's in ASP.NET
Include code:
public List<Recipe> GetRecipes(Cook cook)
{
List<Recipe> L_Recipes = new List<Recipe>();
Cook Cook = dbc.DbCook.Include(c => c.ListRecipes).singleOrDefault(c => c.Nickname == cook.Nickname);
L_Recipes = Cook.ListRecipes;
return L_Recipes;
}
Thx to https://stackoverflow.com/users/395675/philip-smith and https://stackoverflow.com/users/5748194/felipe-deveza
So the answer is Use the Include and add an using
include:public List<Recipe> GetRecipes(Cook cook)
{
List<Recipe> L_Recipes = new List<Recipe>();
Cook Cook = dbc.DbCook.Include(c => c.ListRecipes).singleOrDefault(c => c.Nickname == cook.Nickname);
L_Recipes = Cook.ListRecipes;
return L_Recipes;
}
and the using: using System.Data.Entity;

How to push to do a emdeded document in mongodb c# driver

i have a problem how to push a document into a another document to create a embeded document in c#.
my models look like :
public class ModelKnjiga
{
public ModelKnjiga() { }
[BsonId(IdGenerator = typeof(CombGuidGenerator))] // pojavljuje se greška kod BSON tipa podataka kod ID-a,preuzoteo s dokumentacije drivera 1.5
public Guid Id { get; set; }
[BsonElement("naziv")]
public string naziv { get; set; }
[BsonElement("autor")]
public string autor { get; set; }
[BsonElement("godina_izdanja")]
public string godina_izdanja { get; set; }
[BsonElement("izdavac")]
public string izdavac { get; set; }
[BsonElement("ocjena")]
public String ocjena { get; set; }
[BsonElement("čitam")]
public Boolean čitam { get; set; }
[BsonElement("završio")]
public Boolean završio { get; set; }
}
another model looks like :
public ModelKorisici () {
KnjigaLista = new List<ModelKnjiga>();
}
[BsonId] // pojavljuje se greška kod BSON tipa podataka kod ID-a,preuzoteo s dokumentacije drivera 1.5 CombGuidGenerator
public Guid Identifikator { get; set; }
[BsonElement("ime")]
public string ime { get; set; }
[BsonElement("prezime")]
public string prezime { get; set; }
[BsonElement("lozinka")]
public string lozinka { get; set; }
[BsonElement("email")]
public string email { get; set; }
[BsonElement("kor_ime")]
public string kor_ime { get; set; }
[BsonElement("uloga")]
public string uloga { get; set; }
public List<ModelKnjiga> KnjigaLista { get; set; }
}
and now i am tring to push a modelKnjiga into a modelKorisici
I am trying with this method...
public void dodajKnjiguKorisniku(ModelKnjiga knjiga, Guid id)
{
MongoCollection<ModelKorisici> korisniciKolekcija = GetTasksCollectionKlijenti();
try
{
var pronadiKorisnika = Query<ModelKorisici>.EQ(e => e.Identifikator, id);
var PushPodataka = Update<ModelKorisici>.Push(e => e.KnjigaLista, knjiga);
korisniciKolekcija.Update(pronadiKorisnika, PushPodataka);
}
catch (MongoCommandException ex)
{
string msg = ex.Message;
}
}
In robomongo, the object KnjigaLista is always Null...
Can somebody help?
I think Update is legacy.
(in your models you don't have to use strings only. Eg.: godina_izdanja could be DateTime(), and ocjena some numeric format...)
I made an (async) example with your models, hope it helps:
class Program
{
static void Main(string[] args)
{
MainAsync(args).GetAwaiter().GetResult();
Console.WriteLine("");
Console.WriteLine("press enter");
Console.ReadKey();
}
static async Task MainAsync(string[] args)
{
ModelKnjiga knga = new ModelKnjiga()
{
autor = "Author",
godina_izdanja = "2015",
izdavac = "izdavac",
naziv = "naziv",
ocjena = "20",
završio = true,
čitam = true
};
ModelKnjiga knga2 = new ModelKnjiga()
{
autor = "Author2",
godina_izdanja = "2016",
izdavac = "izdavac2",
naziv = "naziv2",
ocjena = "202",
završio = false,
čitam = false
};
ModelKnjiga knga3 = new ModelKnjiga()
{
autor = "Author3",
godina_izdanja = "2017",
izdavac = "izdavac3",
naziv = "naziv3",
ocjena = "203",
završio = false,
čitam = true
};
ModelKorisici mcor = new ModelKorisici()
{
email = "no#where.com",
ime = "ime",
KnjigaLista = new List<ModelKnjiga>() { knga, knga2 },
kor_ime = "kor_ime",
uloga = "uloga",
lozinka = "lozinka",
prezime = "prezime"
};
var client = new MongoClient();
var db = client.GetDatabase("KnjigaDB");
var korisici = db.GetCollection<ModelKorisici>("Korisici");
//After first run comment this line out
await korisici.InsertOneAsync(mcor);
//After first run UNcomment these lines
//var filter = Builders<ModelKorisici>.Filter.Eq("email", "no#where.com");
//var update = Builders<ModelKorisici>.Update.Push("KnjigaLista", knga3);
//await korisici.UpdateOneAsync(filter, update);
}
}
if you don't like async, change the last line with this:
korisici.UpdateOne(filter, update);

How can I add another parameter to a drop down box?

At the moment I have a drop down box which only displays a Suppliers Name with the value of the ID hidden behind it. I would also like to display the Suppliers account number next to the Supplier Name.
HTML:
#Html.DropDownListFor(
m => m.SupplierID,
new SelectList(Model.Suppliers, "SupplierID", "SupplierName"),
new { #id = "SuppNameDD", #class = "GRDropDown" }
)
Controller:
public ActionResult Index(string client) {
int clientID = clientRepo.GetClientIDByName(client);
DashboardViewModel model = new DashboardViewModel();
model.ClientID = clientID;
model.ClientName = client;
model.FinancialsAtAGlance = reportRepo.GetFinancialsAtAGlance(model.ClientID);
model.SupplierID = -1;
model.AccountNo = null;
model.Suppliers = supplierRepo.GetAllSuppliersByClient(clientID);
model.ReviewID = -1;
model.AccountNo = null;
model.Reviews = reviewRepo.GetAllReviewsByClientID(clientID);
return View(model);
}
ViewModel:
public class DashboardViewModel {
public int ClientID { get; set; }
public string ClientName { get; set; }
public IQueryable<FinancialsAtAGlanceModel> FinancialsAtAGlance { get; set; }
public Dictionary<string, Dictionary<string, decimal?>> Budgets { get; set; }
public class SelectReport {
public int ReportID { get; set; }
public string ReportType { get; set; }
public static IEnumerable<SelectReport> Reports = new List<SelectReport> {
new SelectReport {
ReportID = 1,
ReportType = "Claims By Supplier"
},
new SelectReport {
ReportID = 2,
ReportType = "Department breakdown"
},
new SelectReport {
ReportID = 3,
ReportType = "Reason Code breakdown"
},
new SelectReport {
ReportID = 4,
ReportType = "Monthly Debiting report"
}
};
}
public List<SelectReport> allReports { get; set; }
public int SupplierID { get; set; }
public IEnumerable<Supplier> Suppliers { get; set; }
public int ReviewID { get; set; }
public string AccountNo { get; set; }
public IEnumerable<Review> Reviews { get; set; }
}
How can add this is as the other value is a selected value and this is not what I want. It should be another datatext field.
If this display name is something that would be used multiple times, I would suggest adding a property to your Supplier class. Something like DisplayName:
public class Supplier
{
//...
public string SupplierName { get; set; }
public string AccountNumber { get; set; }
//...
public string DisplayName
{
get { return String.Format("{0} ({1})", SupplierName, AccountNumber); }
}
}
Then, you just need to change your drop down list to use DisplayName instead of SupplierName as the text field:
#Html.DropDownListFor(m => m.SupplierID, new SelectList(Model.Suppliers, "SupplierID", "DisplayName"), new { #id = "SuppNameDD", #class = "GRDropDown" })
EDIT:
There is another way to do this that can be done all in the view:
#Html.DropDownListFor(m => m.SupplierID, Model.Suppliers.Select(item => new SelectListItem
{
Value = item.SupplierID.ToString(),
Text = String.Format("{0} ({1})", item.SupplierName, item.AccountNumber.ToString()),
Selected = item.SupplierID == Model.SupplierID
}))
Probably you can achieve your desired output by 1.create a custom helper with with extension method which will return MvcHtmlString which will create your custom HTML for dropdown and call that method in your view.
Like Below
public static class CustomDropdown
{
public static string Dropdown(Priority priority)
{
StringBuilder sb=new StringBuilder ();
sb+="<Select id='drop'>";
for(int i=0;i<priority.name.length;i++)
{
sb+="<option id='dropop' value='"+priority.value[i]+"'title='"+priority.title[i]+"'>"+priority.name[i]+"</option>";
}
sb+="</select>";
return Convert.ToString(sb);
}
}
2.Bind the options of the given select with help of jquery like
var i=0;
$('.drpclass option').each(function(){
$(this).attr('title',Model.priority.title[i])
i++;
});

how to create my custom control C#?

i try to write my own control.But my control' html has problem: Look like
My Search button look above. But i need below: how can i do that?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls.WebParts; // Ekle
using System.Web.UI.WebControls; // Ekle
using System.Web.UI;
using System.Collections;
using System.Threading;
namespace MyFilterControl
{
public class FilterControl : WebPart
{
internal List<Content> list { get; set; }
public Button BtnSearch { get; set; }
public event EventHandler Click;
public string FilterButtonText { get; set; }
public String PhID { get; set; }
internal PlaceHolder PlhControl { get; set; }
private string controlWidth = "10";
public FilterControl()
{
list = new List<Content>();
BtnSearch = new Button();
PlhControl = new PlaceHolder();
PlhControl.ID = Guid.NewGuid().ToString();
if (string.IsNullOrEmpty(PhID))
{
BtnSearch.ID = "btnSearch";
}
else
BtnSearch.ID = PhID;
if (string.IsNullOrEmpty(FilterButtonText))
{
BtnSearch.Text = "Search";
}
else
BtnSearch.Text = FilterButtonText;
BtnSearch.Click += new EventHandler(BtnSearch_Click);
}
private Table mainTable = new Table();
protected override void CreateChildControls()
{
base.CreateChildControls();
TableRow tblRow = new TableRow();
TableCell tblCell1 = new TableCell();
PlhControl.Controls.Add(new LiteralControl("<table><tr>"));
tblCell1.Controls.Add(PlhControl);
TableCell tblCell2 = new TableCell();
tblCell2.Controls.Add(BtnSearch);
tblRow.Cells.Add(tblCell1);
tblRow.Cells.Add(tblCell2);
mainTable.Rows.Add(tblRow);
this.Controls.Add(mainTable);
}
void BtnSearch_Click(object sender, EventArgs e)
{
PlhControl.Controls.Add(new LiteralControl("</tr><table>"));
foreach (var item in PlhControl.Controls)
{
if (item is MyTextBoxControl)
{
MyTextBoxControl t1 = (MyTextBoxControl)item;
if (t1.Text != "")
{
Add(new Content() { FieldName = t1.ID, Data = t1.Text, ID = Guid.NewGuid().ToString(), dataType = t1.dataType, filter=t1.filter });
}
}
}
Click(this, e);
}
public string Query()
{
string Qry = String.Empty;
int i = 0;
foreach (var item in list)
{
switch (item.filter)
{
case Filter.BeginsWith: Qry += String.Format(item.FieldName.ToString() + ".StartsWith({0}) && ", "#" + i.ToString());
break;
case Filter.EndsWith: Qry += String.Format(item.FieldName.ToString() + ".EndsWith({0}) && ", "#" + i.ToString());
break;
case Filter.Contains: Qry += String.Format(item.FieldName.ToString() + ".Contains({0}) && ", "#"+i.ToString());
break;
case Filter.Default: Qry += String.Format("{0}=={1} && ", item.FieldName, "#" + i.ToString());
break;
default:
break;
}
i++;
}
Qry = Qry.TrimEnd('&', '&', ' ');
return Qry;
}
public object[] QueryParams()
{
ArrayList arrList = new ArrayList();
foreach (var item in list)
{
if (item.dataType == DataType.String)
arrList.Add(item.Data);
else if (item.dataType == DataType.Int32)
{
int intVal = Convert.ToInt32(item.Data);
arrList.Add(intVal);
}
}
object[] strArray = arrList.ToArray(typeof(object)) as object[];
return strArray;
}
public string id { get; set; }
public void AddItem(ContentItem content)
{
PlhControl.Controls.Add(new LiteralControl("<td style=\"text-align:left\">"));
PlhControl.Controls.Add(new Label() { ID = Guid.NewGuid().ToString(), Text = content.LabelName });
PlhControl.Controls.Add(new LiteralControl(":</td>"));
PlhControl.Controls.Add(new LiteralControl("<td style=\"text-align:left\">"));
PlhControl.Controls.Add(new MyTextBoxControl() { ID = content.FieldName, dataType = content.dataType, filter = content.filter });
PlhControl.Controls.Add(new LiteralControl("</td>"));
}
private void Add(Content content)
{
list.Add(new Content() { ID = content.ID, Data = content.Data, FieldName = content.FieldName, dataType=content.dataType, filter= content.filter });
}
}
internal class Content
{
internal string ID { get; set; }
public string Data { get; set; }
public string FieldName { get; set; }
public DataType dataType { get; set; }
public Filter filter { get; set; }
}
public class ContentItem
{
private string ID { get; set; }
public string LabelName { get; set; }
public string FieldName { get; set; }
public DataType dataType { get; set; }
public Filter filter { get; set; }
}
public class MyTextBoxControl : TextBox
{
public DataType dataType { get; set; }
public Filter filter { get; set; }
}
public enum DataType
{
String,Int32
}
public enum Filter
{
BeginsWith,EndsWith,Contains,Default
}
}
You can place each control in a table cell. Or you can place everything in a div with a fixed heigh.

Categories