This is a migrated thread and some comments may be shown as answers.

How can i pass values to Barcode from database ?

2 Answers 122 Views
Barcode
This is a migrated thread and some comments may be shown as answers.
Ahmed
Top achievements
Rank 2
Ahmed asked on 13 Apr 2015, 08:18 PM

Hi

Please sir, i have add barcode in my view and it works as code:

 

@(Html.Kendo().Barcode()
    .Name("manchego")
    .Value("2346722")
    .Encoding(BarcodeSymbology.EAN8)
    .Width(200)
    .Height(100)
)

now i need to pass value to barcode from EmployeeViewModel for each employee to let me view them in my page as example :

   <ul id="dairy">
            <li>
@* here pass value for employee 1 *@
@(Html.Kendo().Barcode().Name("manchego").Value("2346722").Encoding(BarcodeSymbology.EAN8).Width(200).Height(100))
            </li>
            <li>
@* here pass value for employee 2 *@
@(Html.Kendo().Barcode().Name("mascarpone").Value("Mascarpone").Encoding(BarcodeSymbology.Code128).Width(200).Height(100))
            </li>
            <li>
@* here pass value for employee 3 *@
@(Html.Kendo().Barcode().Name("gudbrands").Value("CHEESE").Encoding(BarcodeSymbology.Code39).Width(200).Height(100))
            </li>
        </ul>

and ect ..... for any other employee

 so please how can i do that ?

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 15 Apr 2015, 10:58 AM
Hello,

I am note sure if I understand the issue but you could pass the Model value to the Value method:
@(Html.Kendo().Barcode()
    .Name("manchego")
    .Value(Model.BarcodeValue)
    .Encoding(BarcodeSymbology.EAN8)
    .Width(200)
    .Height(100)
)
If you have multiple items then you could iterate over each one and render a barcode:
@model IEnumerable<EmployeeViewModel>
 
@foreach (var item in Model)
{
    @(Html.Kendo().Barcode()
        .Name("manchego" + item.IDField)
        .Value(item.BarcodeValue)
        .Encoding(BarcodeSymbology.EAN8)
        .Width(200)
        .Height(100)
    )
}


Regards,
Daniel
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Ahmed
Top achievements
Rank 2
answered on 15 Apr 2015, 01:50 PM
Thanks a lot .... i will try and then feedback you ....
Tags
Barcode
Asked by
Ahmed
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Ahmed
Top achievements
Rank 2
Share this question
or