How to use Format: Webgrid?

Asked

Viewed 276 times

5

I am developing with MVC, and I have the List view

[...]

var columns = new WebGridColumn[] {
        grid.Column("Id"),
        grid.Column("Descricao"),
        grid.Column("UsuarioModificacao"),
        grid.Column("DataModificacao"),
        grid.Column("UltimoLogAcesso.DataAcesso"),
        grid.Column("UltimoLogAcesso.Ip"),
        grid.Column("UrlChamadaAlerta", format: (grid) => string.Format("{Id}")),
        grid.Column("FlagBloqueioPainel"),
        grid.ButtonColumn("ico_permission.gif", x => Url.Action("ConfirmarExclusao", "PainelChamada", new { id = x.Id } ), updateTargetId: "console"),

I need to format the column Urlchamadawarning that should be in this format

painel.ejis.com.br/?id=<PainelChamada.ID>&token=<PainelChamada.GuidPainelChamada > 

I’ll use the ID and the Guid that are on the model Painelchamada

        public int Id {get; set;}
        public System.Guid Guid { get; set; }

Guys, it would be right to create routes, but for now the format will suit my purpose. Obs.: how will be used the format certain properties that would be made with the routes need not look perfect. My Format is wrong, but my difficulty is to assemble the correct expression.

grid.Column("UrlChamadaAlerta",
            format: dataItem =>
                    string.Format("painel.ejis.com.br?id={0}&token={1}",
                                  dataItem.Id,
                                  dataItem.Guid),

Here’s a tip for those who need it!

1 answer

0


grid.Column("UrlChamadaAlerta",
            format: dataItem =>
                    string.Format("painel.ejis.com.br?id={0}&token={1}",
                                  dataItem.Id,
                                  dataItem.Guid),

Here’s a tip for those who need it!

  • 1

    What is the difference of this code with what is in the question?

  • The answer in the question the Gypsy edited and added.

  • Thamires please accept the answer otherwise the question will remain open.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.