Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datalist with Edit link 1

Status
Not open for further replies.

ecannizzo

Programmer
Sep 19, 2000
213
US
I have a datalist that has a column where an edit link is. The code for that part of the itemtemplate looks like:

Code:
<td valign="bottom" nowrap>			<asp:Linkbutton Runat="server" ID="Edit" CSSclass="RegularText" CommandName='E' Text='Edit'>
	</asp:Linkbutton>
</td>

There is a scenario where I don't want to show this column or I atleast don't want to show the link. Does anyone have an idea on how to do this?

Thanks!
 
Try using the ItemDataBound event of the datalist to get a reference to the link.

Something like this:
Code:
..ItemDataBound event of DataList ..
Dim lb as new LinkButton
lb = e.Item.FindControl("Edit")

'Then check your condition..
If Something is TRUE Then
   lb.Visible = TRUE
ELSE
  lb.Visible = FALSE
End IF

Hope this helps ..

Jim
 
Use the ItemDataBound event and get a reference to the LinkButton using FindControl (you can then hide it based on your logic).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks!

This is what I did:

Code:
private void DataList_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{
if(( e.Item.ItemType == ListItemType.Item)||( e.Item.ItemType == ListItemType.AlternatingItem)) 
{ 
	LinkButton lbEdit = new LinkButton();
        lbEdit = (LinkButton)e.Item.FindControl("Edit");

	if (bool.Parse(somebool.ToString()) == true) 
	{ 
	lbEdit.Visible = true;
								}
	else 
	{
	lbEdit.Visible = false;
								}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top