this.DataList1.Items[0].FindControl("Label").Visible = true; // just to disable
(this.DataList1.Items[0].FindControl("Label") as Label).Visible = true; // to get control
or
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
(e.Item.FindControl("Label") as Label).Visible= false;
}}
foreach (DataListItem item in DataList1.Items)
{
HiddenField hf = item.FindControl("hField") as HiddenField; // Declare the hidden field in the design.
if (hf != null && string.IsNullOrEmpty(hf.Value)) // Checking file is null or not.
{
LinkButton btn = item.FindControl("linkview") as LinkButton;
if (btn != null)
{
btn.Visible = false;
}
}
}
Prathamesh.s...
Member
16 Points
71 Posts
datalist control
Dec 06, 2011 05:42 PM|LINK
How do I find a control within a datalist item template ?
and how do i visible and enable it
Prathamesh shende
Chetan Chopa...
Participant
1980 Points
347 Posts
Re: datalist control
Dec 06, 2011 05:44 PM|LINK
Simplest way is to use jQuery.
i.e. javascript get the control and do visible it or enable or disable
Refer:
http://etgconsultancy.com/jquery/Jquery-Repeater-Gridview.aspx
SilverAsp
Member
282 Points
89 Posts
Re: datalist control
Dec 06, 2011 05:47 PM|LINK
r u telling about control inside grid
mark the post as Answer if it helps
salman beher...
All-Star
30547 Points
5841 Posts
Re: datalist control
Dec 07, 2011 04:35 AM|LINK
Hi,
like...
protected void DataList1_ItemDataBound
(object sender, DataListItemEventArgs e)
{
GridView GridView1=(GridView)e.Item.FindControl("GridView1");
TextBox txt=(TextBox)e.Item.FindControl("TextBox1");
}
Thanks...
Sincerely,
Salman
vijay_myl
Contributor
5070 Points
1068 Posts
Re: datalist control
Dec 07, 2011 05:21 AM|LINK
Refer this article........
http://vbdotnetaddict.blogspot.com/2011/07/how-to-updatedelete-and-edit-in.html
My .NET blog
Submit Article
sujeet_kumar
Member
198 Points
55 Posts
Re: datalist control
Dec 07, 2011 05:28 AM|LINK
Hi
protected void dlCategory_ItemDataBound(object sender, DataListItemEventArgs e) { Label Label1 = e.Item.FindControl("Label1") as Label; Label1.Visible= true }Software Developer
MCTS,MCPD
Prathamesh.s...
Member
16 Points
71 Posts
hide the control which are inside the datalist Control
Dec 31, 2011 10:49 AM|LINK
How do i hide the link button control which in the DataList Control
plz help ..................................
Prathamesh shende
Prathamesh.s...
Member
16 Points
71 Posts
Re: datalist control
Dec 31, 2011 10:55 AM|LINK
sir , its not working its give error "Object reference not set to an instance object "
Prathamesh shende
karthicks
All-Star
31334 Points
5414 Posts
Re: hide the control which are inside the datalist Control
Dec 31, 2011 11:39 AM|LINK
this.DataList1.Items[0].FindControl("Label").Visible = true; // just to disable (this.DataList1.Items[0].FindControl("Label") as Label).Visible = true; // to get control or protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { (e.Item.FindControl("Label") as Label).Visible= false; }}Karthick S
salman beher...
All-Star
30547 Points
5841 Posts
Re: datalist control
Jan 02, 2012 04:36 AM|LINK
Hi,
it should be work..
foreach (DataListItem item in DataList1.Items) { HiddenField hf = item.FindControl("hField") as HiddenField; // Declare the hidden field in the design. if (hf != null && string.IsNullOrEmpty(hf.Value)) // Checking file is null or not. { LinkButton btn = item.FindControl("linkview") as LinkButton; if (btn != null) { btn.Visible = false; } } }protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { LinkButton lb=e.Item.FindControl("editButton") as LinkButton; if(lb!=null){ if(some condition){ lb.Visible=false; } } }Sincerely,
Salman