Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
444
Webdatagrid make a cell a link? Im using Templates
posted

I wrote a Template Class that inherits from ITemplate. In InstansiateIn I create a div and add a handler for databinding, during the databinding event, I want to make the entire cell a clickable link. I can add an onclick attribute and javascript to accomplish this, my problem is that I cannot get a reference to the table cell, only the div and the TemplateContainer object which doesn't have an attributes collection. Any ideas on how I can reference the cell? This is what I have so far...

Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn

 

 

Dim div As New Panel
div.CssClass = "divLink"
AddHandler div.DataBinding, AddressOf Me.BindData
container.Controls.Add(div)

 

 

End Sub

 

 

 

Public Sub BindData(ByVal sender As Object, ByVal e As EventArgs)

 

 

Dim div = DirectCast(sender, Panel)
Dim container As TemplateContainer = DirectCast(div.NamingContainer, TemplateContainer)
Dim drv as DataRowView = DirectCast(container.DataItem, DataRowView)

Dim url = String.Format("~/ContractEntry3.aspx?d={0}&pid={1}", drv(1), _product.PROD_ID)

 

div.Attributes.Add("onclick", String.Format("BLOCKED SCRIPTlocation.href='ContractEntry3.aspx?d={0}pid={1}'", drv(1), _product.PROD_ID))

 

 

End Sub

 

Any help would be appreciated.

Thanks,

~ck

Parents
No Data
Reply
  • 49378
    posted

    Hi hcabnettek,

    I know it has been a while since you created this thread but in case you still need help I would be glad to assist you. This answer may also prove useful to other community members.

    From what I understand you need to access the specific cell which was clicked. You could do this by handling the Selection.CellSelectionChanged event. Keep in mind that you need to set the AutoPostback on cell selection to true for this to work.

    In the handler you can check the column and row indexes of the component that fired that event. This is necessary as selecting any cell of the grid would fire the event. Afterwards, you should be able to modify your application and achieve the desired clickable cell functionality.

    Please contact me if you require further assistance.

    Petar Ivanov
    Developer Support Engineer
    Infragistics, Inc.
    http://www.infragistics.com/support

Children
No Data