Sunday, November 02, 2008

Not rocket science, just put here for my own future reference.

We want to add User Actions to each row of a datagrid.  Using the DevExpress ASPxGridView control, we create a DataColumn and then add a DataItemTemplate to this.

In the code in-front, add the following reference to code-behind:

<p><%#MakeActions(Container.DataItem)%></p>

In the code-behind, the MakeActions method should look something like th

        public string MakeActions(object dataItem)
        {
            StringBuilder sb = new StringBuilder();
            int id = Convert.ToInt32(DataBinder.Eval(dataItem, "ID").ToString());
            sb.Append("<a href=\"" + "Details.aspx?id=" + id.ToString() + "\"><img border=0 alt='Open Record' src='Images/folder_go.png'></a>");
            return sb.ToString();
        }

where DataItem is the bound data object of that row.  Clicking on this item will therefore link to the Details.aspx page, passing through the id on the querystring.

Sunday, November 02, 2008 1:52:33 PM (GMT Standard Time, UTC+00:00) | Comments [0] | ASP.NET#
Search
Archive
Links
Categories
Admin Login
Sign In
Blogroll