Im using MVC-Viewmodel, EF Model first on my project.
I have a foreach loop that generates 4 tables inside my view. I want that each table that generates gets an unique ID. I guess that I have to do this inside my ViewModel.
Any kind help is appreciated All I know is that I need to declare something like this inside my foreach loop:
<table id="RandomID_@("MyRandomProperty)">
and probably a property like this:
public random MyRandomProperty {get;set;}
Thanks in advance!
You could use a Guid:
<table id="RandomID_@(Guid.NewGuid())">
How about using a GUID as your ID property?
private Guid _tableId;
public Guid TableId = {
get {
if(_tableId == null)
_tableId = Guid.NewGuid();
return _tableId;
}
}
Or you could just call Guid.NewGuid()
inline in your View? Dependes if you need to access the ID from else where in your code...
Hope this helps,
James
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With