Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. @Html.DevExpress().GridView(settings =>
  2. {
  3. //General settings
  4. settings.Name = "name";
  5. settings.KeyFieldName = "ID";
  6. //Other settings etc.....
  7.  
  8. settings.Columns.Add(column =>
  9. {
  10. column.Name = "Name";
  11. column.FieldName = "CurrentFieldBoundToColumn";
  12. column.Caption = "Some caption";
  13.  
  14. //Set hyperlink
  15. column.ColumnType = MVCxGridViewColumnType.HyperLink;
  16. var hyperLinkProperties = column.PropertiesEdit as HyperLinkProperties;
  17. String urlFormatString = Url.Action("Action", "Controller", new RouteValueDictionary(new { ID= "{0}" }));
  18. hyperLinkProperties.NavigateUrlFormatString = HttpUtility.UrlDecode(urlFormatString);
  19.  
  20.  
  21. });
  22. //Other Columns etc etc
  23. });
  24.  
  25. settings.Columns.Add(column =>
  26. {
  27. column.Name = "Name";
  28. column.FieldName = "CurrentFieldBoundToColumn"";
  29. column.Caption = "SomeCaption";
  30.  
  31. //Set hyperlink
  32. column.SetDataItemTemplateContent(content =>
  33. ViewContext.Writer.Write
  34. (
  35. Html.ActionLink
  36. (
  37. linkText: content.Text,
  38. actionName: "Action",
  39. controllerName: "Controller",
  40. routeValues: new { ID = content.KeyValue },
  41. htmlAttributes: null
  42. )
  43. ));
  44. });
  45.  
  46. @Html.DevExpress().GridView(settings =>
  47. {
  48. //General settings
  49. settings.Name = "name";
  50. settings.KeyFieldName = "ID";
  51. //Other settings etc.....
  52.  
  53. settings.Columns.Add(column =>
  54. {
  55. column.Name = "Name";
  56. column.FieldName = "CurrentFieldBoundToColumn";
  57. column.Caption = "Some caption";
  58.  
  59. column.SetDataItemTemplateContent(content =>
  60. ViewContext.Writer.Write(
  61. Html.ActionLink(content.Text, "Action", "Controller",
  62. new { ID = content.KeyValue }, null)));
  63. });
  64. //Other Columns etc etc
  65. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement