locked
Help adding a 2nd paramater RRS feed

  • Question

  • User1463147114 posted

    Hi.

    I have this statement in a Webmatrix Webgrid:

    grid.Column(format: @<text>@(item.EmailAddress == "Email" ? Html.Raw("<a href=\"CustomerEmail.cshtml?id=" + item.CustomerId + "\">Email </a>") : "")</text>),

    It works fine but now I need to enhance this to add a second parameter that is the url of the existing page so I can Response.Redirect back to it.

    Is this possible?

    Saturday, August 17, 2013 12:15 PM

Answers

  • User-183374066 posted

    You can add second column the same way you add first column

    @grid.GetHtml(
        tableStyle : "table",
        alternatingRowStyle : "alternate",
        headerStyle : "header",
        columns: grid.Columns(
    
            grid.Column(
                columnName : "Author",
                format: @<text>@item.FirstName @item.LastName</text>
                ),
            grid.Column(
                columnName : "Title",
                format: @<text>@item.Title</text>
                ),
            grid.Column(
                columnName : "Category"
                )
        )
    )

    http://www.mikesdotnetting.com/Article/168/The-WebGrid-Helper-Making-Selections

    and also look at following article which is very helpful

    http://www.mikesdotnetting.com/Article/202/Inline-Editing-With-The-WebGrid

    Edited:

    jw7965

    I'm not trying to add a 2nd column to my table, I want to add a 2nd paramater along with CustomerId when I pass control to CustomerEmail.cshtml.

    Sorry my bad. You can add second parameter similarly you add first one

    grid.Column(format: @<text>@(item.EmailAddress == "Email" ? Html.Raw("<a href=\"CustomerEmail.cshtml?id=" +
    item.CustomerId + "&url=" + Request.Url + "\">Email </a>") : "")</text>),

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 17, 2013 12:32 PM
  • User-821857111 posted

    <a href=\"CustomerEmail.cshtml?id=" + item.CustomerId + "&returnUrl=" + Request.Url + "\">

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 17, 2013 1:32 PM

All replies

  • User-183374066 posted

    You can add second column the same way you add first column

    @grid.GetHtml(
        tableStyle : "table",
        alternatingRowStyle : "alternate",
        headerStyle : "header",
        columns: grid.Columns(
    
            grid.Column(
                columnName : "Author",
                format: @<text>@item.FirstName @item.LastName</text>
                ),
            grid.Column(
                columnName : "Title",
                format: @<text>@item.Title</text>
                ),
            grid.Column(
                columnName : "Category"
                )
        )
    )

    http://www.mikesdotnetting.com/Article/168/The-WebGrid-Helper-Making-Selections

    and also look at following article which is very helpful

    http://www.mikesdotnetting.com/Article/202/Inline-Editing-With-The-WebGrid

    Edited:

    jw7965

    I'm not trying to add a 2nd column to my table, I want to add a 2nd paramater along with CustomerId when I pass control to CustomerEmail.cshtml.

    Sorry my bad. You can add second parameter similarly you add first one

    grid.Column(format: @<text>@(item.EmailAddress == "Email" ? Html.Raw("<a href=\"CustomerEmail.cshtml?id=" +
    item.CustomerId + "&url=" + Request.Url + "\">Email </a>") : "")</text>),

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 17, 2013 12:32 PM
  • User1463147114 posted

    Hi.

    I'm not trying to add a 2nd column to my table, I want to add a 2nd paramater along with CustomerId when I pass control to CustomerEmail.cshtml.

    Cheers.

    Saturday, August 17, 2013 1:06 PM
  • User-821857111 posted

    <a href=\"CustomerEmail.cshtml?id=" + item.CustomerId + "&returnUrl=" + Request.Url + "\">

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 17, 2013 1:32 PM
  • User1463147114 posted

    Works wonderful, thx Mike.

    Saturday, August 17, 2013 5:53 PM