How can i pass values to Barcode from database ?

3 posts, 1 answers
  1. Ahmed Amin
    Ahmed Amin avatar
    34 posts
    Member since:
    Apr 2015

    Posted 13 Apr 2015 Link to this post

    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. Answer
    Daniel
    Admin
    Daniel avatar
    2118 posts

    Posted 15 Apr 2015 Link to this post

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Ahmed Amin
    Ahmed Amin avatar
    34 posts
    Member since:
    Apr 2015

    Posted 15 Apr 2015 Link to this post

    Thanks a lot .... i will try and then feedback you ....
Back to Top