<asp:LinkButton id="linkCompany" runat="server" OnClientClick='window.open("PopupCompDtls.aspx?id=<%# EncrID(Eval("CompanyID"))%>&cheksec=1","DaybWindow","height=800,width=1075,scrollbars=yes")'>
<%#Eval("Company")%></asp:LinkButton>
and in your code behind
LinkButton link = (LinkButton )e.Row.Cells[10].FindControl("linkCompany") ;
Two things first you are disabling the kink on row databound I m sure there must be a condition what is that coz it can easily be done in jquery if the condition is client side
secondly the link button code i posted works and the onclient click was working too, what is the issue you are facing
lumip
Member
132 Points
105 Posts
Grid row data bound find control problem
Oct 14, 2011 09:25 AM|LINK
I hav a grid view
one column containes hyper link.
HyperLink link = e.Row.Cells[10].FindControl("linkCompany") as HyperLink;jayeshgoyani
Contributor
2394 Points
424 Posts
Re: Grid row data bound find control problem
Oct 14, 2011 09:31 AM|LINK
try with below code
System.Web.UI.HtmlControls.HtmlAnchor link = e.Row.Cells[10].FindControl("linkCompany") as System.Web.UI.HtmlControls.HtmlAnchor ;
http://abhijitjana.net/2011/09/01/dynamically-set-control-visibility-inside-itemtemplates-of-gridview-using-bind-expression/
MCP
My Blog
abiruban
All-Star
16048 Points
2734 Posts
Re: Grid row data bound find control problem
Oct 14, 2011 10:35 AM|LINK
hi
http://stackoverflow.com/questions/121722/getting-value-from-a-cell-from-a-gridview-on-rowdatabound-event
http://forums.asp.net/t/1096012.aspx/1
***DON'T FORGET TO CLICK “MARK AS ANSWER” ON THE POST IF HELPED YOU.
mkonanki
Contributor
2820 Points
624 Posts
Re: Grid row data bound find control problem
Oct 14, 2011 10:47 AM|LINK
Hi,
your above code is corret but if condition is wrong, check below
protected void gdSearchResults_OnRowdataBound(Object sender, GridViewRowEventArgs e)
{
GridViewRow row = e.Row;
if ((e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Footer) && (e.Row.RowIndex >= 0))
{
HyperLink link == row.FindControl("linkCompany") as HyperLink;
link.Visible=false;
}
lumip
Member
132 Points
105 Posts
Re: Grid row data bound find control problem
Oct 14, 2011 10:51 AM|LINK
System.Web.UI.HtmlControls.HtmlAnchor link = e.Row.Cells[10].FindControl("linkCompany") as System.Web.UI.HtmlControls.HtmlAnchor ;
your code works better for one section . but makes error on onther section.
the hyper link is active in one section where a pop up hapens... its not working..
pls help
thanx.
kratos_Vimal
Contributor
3744 Points
960 Posts
Re: Grid row data bound find control problem
Oct 14, 2011 10:54 AM|LINK
use a link button instead of a hyperlink
<asp:LinkButton id="linkCompany" runat="server" OnClientClick='window.open("PopupCompDtls.aspx?id=<%# EncrID(Eval("CompanyID"))%>&cheksec=1","DaybWindow","height=800,width=1075,scrollbars=yes")'> <%#Eval("Company")%></asp:LinkButton> and in your code behindLinkButton link = (LinkButton )e.Row.Cells[10].FindControl("linkCompany") ;Vimal
lumip
Member
132 Points
105 Posts
Re: Grid row data bound find control problem
Oct 15, 2011 03:49 AM|LINK
Thanx Vimal..
It works for disabling the link button. . The client side java script function is not working.(Onclientclick)
Pls help me.
kratos_Vimal
Contributor
3744 Points
960 Posts
Re: Grid row data bound find control problem
Oct 15, 2011 05:43 AM|LINK
Whats th error you are getting
Vimal
lumip
Member
132 Points
105 Posts
Re: Grid row data bound find control problem
Oct 15, 2011 06:18 AM|LINK
thanx kratos_Vimal..
I need to get the html href control in my code behind.. Can I get the html control using find control method?
My code is below...
In grid I have column company..
<asp:TemplateField HeaderText="Company" SortExpression="Company" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"> <ItemTemplate> <a id="linkCompanyg" href="#" onclick='window.open("PopupCompDtls.aspx?id=<%# EncrID(Eval("CompanyID"))%>&cheksec=1","DaybWindow","height=800,width=1075,scrollbars=yes")' > <%#Eval("Company")%></a> </ItemTemplate>protected void gdSearchResults_OnRowdataBound(Object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { System.Web.UI.HtmlControls.HtmlAnchor link = e.Row.FindControl("linkCompany") as System.Web.UI.HtmlControls.HtmlAnchor; if (link != null) { link.Enabled = false; } } }kratos_Vimal
Contributor
3744 Points
960 Posts
Re: Grid row data bound find control problem
Oct 15, 2011 06:41 AM|LINK
Two things first you are disabling the kink on row databound I m sure there must be a condition what is that coz it can easily be done in jquery if the condition is client side
secondly the link button code i posted works and the onclient click was working too, what is the issue you are facing
Vimal