Hi, I am migrating from 11.1 to 13.2, I have this code in the click event of a link that's inside a templateDataField in a WebHierarchicalGrid:
protected void lnkEditBoard_Click(object sender, EventArgs e) { var replacementDate = GetRateGridCurrentRow().Items.FindItemByKey("ReplacementDate").Value as DateTime?;
LinkButton lnk = sender as LinkButton;
CellItem parentCell = (CellItem)lnk.NamingContainer;
var BoarId = parentCell.Cell.Row.Items.FindItemByKey("BoardId").Value.ToString();
}
Here's the templateDataField:
<ig:TemplateDataField Width="310px" Key="lnkBoardsColumn"> <ItemTemplate> <asp:LinkButton ID="lnkEditBoard" OnClick="lnkEditBoard_Click" runat="server" ForeColor="Navy"> <%# DataBinder.Eval(Container, "DataItem.Description")%> </asp:LinkButton> </ItemTemplate> <FooterTemplate> <asp:LinkButton ID="lnkAddBoard" OnClick="lnkAddBoard_Click" runat="server" ForeColor="Black" Font-Bold="true" Font-Size="X-Small">Add Board</asp:LinkButton> </FooterTemplate> <Footer CssClass="footerStyle"> </Footer> </ig:TemplateDataField>
Hello Nicole,
In order to get WebHierarchicalDataGrid property such as which row contains the clicked link it is needed events associated with the WebHierarchicalDataGrid to be handled. Hyper link clicking events are not registered as WebHierarchicalDataGrid events and that’s why the grid properties are not available as handler function input parameters.
Examples for appropriate for this purpose events are the activation feature events.
I have implemented the active cell changed event on the server-side:
protected void ActiveCellChanged(object sender, Infragistics.Web.UI.GridControls.ActiveCellEventArgs e)
{
var activeCell = e.CurrentActiveCell;
if (activeCell.Column.Key == "ProductName")
var activeRowId = activeCell.Row.Items[0].Text;
It is checked in which column is the active cell. In your scenario it could be checked if this is the hyperlink column.
The client side code is added below:
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" "
OnActiveCellChanged="ActiveCellChanged" …">
<Behaviors>
…
<ig:Activation>
<AutoPostBackFlags ActiveCellChanged="True" />
</ig:Activation>
</Behaviors>
I have attached a working sample for your reference.
If you have any further questions, concerns or comments don’t hesitate to contact me again.
Hi, sorry for the delay.
I need a c# function, not a javascript, and I need to handle the onclick of the link, not the activation of the cell, it's absolutely not the same thing.
Please, read my post carefully!
I really hope you can help me.
Thank you.
I have revised this further. One possible approach which I could suggest is enabling the activation feature and handling its ActiveCellChanged client side event. I have added code snippets below to illustrate this solution (see in bold):
<script type="text/javascript">
function ActiveRow_Changed(sender, eventArgs)
if (eventArgs.getActiveCell() !== null) {
if (eventArgs.getActiveCell()._column._key === "LinkField") {
var a = eventArgs.getActiveCell().get_row().get_cell(0).get_value();
// your code using the row id
</script>
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="349px" Width="463px"
AutoGenerateColumns="False" EnableAjax="False" DataKeyFields="id">
<Columns>
<ig:TemplateDataField Key="LinkField">
<Header Text="TemplateField" />
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>
</ItemTemplate>
</ig:TemplateDataField>
</Columns>
<ig:Activation ActivationClientEvents-ActiveCellChanged="ActiveRow_Changed">
</ig:WebDataGrid>
In the ActiveRow_Changed function it is checked is the current active row is empty and if it is in the column which is needed to be processed (in this case the column containing the links).
I have also attached the whole sample for your reference. Feel free to modify it and use it if needed.
Hope this helps. If you have further questions or concerns don’t hesitate to contact me again.
Yes, my code is not compiling, of course. Because the "CellItem" does not longer exist, if you read my post carefully, I make it clear that I am migrating from 11.1 to 13.2, hence I need yo re-write my code.
I have a template field with a link inside it, on the "onclick" event of that link I need to obtain which row contains the clicked link.
In my 11.1 I did it like this:
protected void lnkEditBoard_Click(object sender, EventArgs e) {
var row = parentCell.Cell.Row;
but as I said earlier, I no longer have the CellItem class, since I am migrating to 13.2
Thank you for your help.
Thank you for posting in our forum.
Please note that code re-writing will be only needed if you are shifting from the retired classic controls to the new Aikido-based ones. NetAdvantage 2011.1 contains both the classic and the new packages of controls. As far as I could understand from your code snippet you it seems that you are already using the new controls so this code is expected to work in 13.2.
Have you encountered any issues while implementing this code with 13.2?
I have added below for your reference articles describing the item template implementation in 13.2:
http://help.infragistics.com/Doc/ASPNET/2013.2/CLR4.0/?page=WebDataGrid_Using_Item_Template.html
http://help.infragistics.com/Help/Doc/ASPNET/2013.2/CLR4.0/html/WebHierarchicalDataGrid_Using_Item_Template.html
If you need any further assistance please let me know.