I was searching through the old forums trying to figure out how to bind a value to a Templated Column that is using an Web Image Button. For the most part, I saw unanswered posts from a long time ago. I finally found the answer, so I will post it:
This is what the column code looks like for the grid in the aspx page:
<igtbl:TemplatedColumn Key="RecId" BaseColumnName="RecId" AllowRowFiltering="false" Width="25px">
<CellTemplate>
<igtxt:WebImageButton ID="btnLink" runat="server"
CssClass="pointer"
OnCommand="btnLink_Command" CommandArgument="<%# Container.Value%>" ToolTip="Edit Security">
<Appearance>
<Image Url="~/Image/icon/ico_edit.gif" />
</Appearance>
</igtxt:WebImageButton>
</CellTemplate>
</igtbl:TemplatedColumn>
Here is the code behind button command event:
{
}
I do have one other question though, is it possible to send the data for more than one column or the entire row using the code above?
The answer is, yes it's possible and you're pretty much there. The "Container" in the template is an instance of the "CellItem" class (http://help.infragistics.com/Help/NetAdvantage/NET/2007.3/CLR2.0/html/Infragistics2.WebUI.UltraWebGrid.v7.3~Infragistics.WebUI.UltraWebGrid.CellItem_members.html) which has a "Cell" property that can be used to walk up the chain in the grid. In your case, if you want to get to another cell, use Container.Cell.Row.Cells[index].Value
Hope this helps. I'll be forwarding this post on to our Docs team and pursue getting a topic written up on this as well.
-Tony
Hey Tony, Thanks a lot for the answer. Is it possible for me to access the row info in the code behing in the command method. I would rather not have to pass the whole row in some kind of concatenated list?
What I ended up doing in one case was this:
<igtxt:WebImageButton ID="btnView" runat="server"
CommandArgument="<%# Container.Value%>" CssClass="pointer"
OnCommand="btnView_Command" ToolTip="View this Message">
<Image Url="~/Image/icon/ico_view.gif" />
string Val = e.CommandArgument.ToString();
Session["RefreshNotes"] = "Yes";
This is kind of a backwards way to access the row, as is passing multiplte cell values in the command argument.
I would like to be able to just pass in a pointer to the row, similar to how a row click event works??