Am trying to access a control in the emptydata item template to disable it for certain users. My template looks like this:
The function in the "visible" attribute isn't firing, yet the exact same button is in the Item template and it fires ok there.
I also can't find a FindControl function for the empty item in code..but i can for the other templates.
So how would i go about accessing that control?
Many thanks
James
<
EmptyDataTemplate
>
This staff member currently has no blogs.
<
br
/>
<
asp:LinkButton
ID
=
"lnkBtnAddBlog"
runat
=
"server"
CommandName
=
"AddBlog"
Visible="<%# AllowUserEdits() %>"> Add new blog</
asp:LinkButton
>
</
EmptyDataTemplate
>
The function in the "visible" attribute isn't firing, yet the exact same button is in the Item template and it fires ok there.
I also can't find a FindControl function for the empty item in code..but i can for the other templates.
So how would i go about accessing that control?
Many thanks
James
6 Answers, 1 is accepted
0
Hi James,
You may consider using the Load event of the LinkButton to set its visibility instead.
Greetings,
Rosen
the Telerik team
You may consider using the Load event of the LinkButton to set its visibility instead.
Greetings,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
James
Top achievements
Rank 1
answered on 08 Sep 2010, 09:39 AM
Hi,
Thanks for the reply. I'd never thought of the Load event for the control itself, that seems a smart idea.
For the time being I moved my control below the listview and dealt with it there instead as it's position wasn't vital.
So there's no equivalent of FindControl for empty templates?
Thanks,
James :-)
Thanks for the reply. I'd never thought of the Load event for the control itself, that seems a smart idea.
For the time being I moved my control below the listview and dealt with it there instead as it's position wasn't vital.
So there's no equivalent of FindControl for empty templates?
Thanks,
James :-)
0
Hello James,
Indeed, you can use FindControl to get reference to the LinkButton, by hooking to ItemCreated event, similar to the following:
Greetings,
Rosen
the Telerik team
Indeed, you can use FindControl to get reference to the LinkButton, by hooking to ItemCreated event, similar to the following:
protected
void
RadListView1_ItemCreated(
object
sender, Telerik.Web.UI.RadListViewItemEventArgs e)
{
if
(e.Item
is
RadListViewEmptyDataItem)
{
Debug.Assert(e.Item.FindControl(
"lnkBtnAddBlog"
) !=
null
);
}
}
Greetings,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
James
Top achievements
Rank 1
answered on 08 Sep 2010, 11:21 AM
Thanks very much again.. That would do the trick I think.. I'm still just getting used to the control :-)
I wonder if there would be a way in future to do it like with the other templates:
RadListViewStaffBlog.InsertItem.FindControl("----")
One further question regarding the ItemCreated event.. or the ItemDataBound.
How would one get the value of the datakey from these events?
Thanks for all the help, much appreciated.
James :-)
I wonder if there would be a way in future to do it like with the other templates:
RadListViewStaffBlog.InsertItem.FindControl("----")
One further question regarding the ItemCreated event.. or the ItemDataBound.
How would one get the value of the datakey from these events?
Thanks for all the help, much appreciated.
James :-)
0
Hello James,
You may use RadListViewDataItem GetDataKeyValue method:
Regards,
Rosen
the Telerik team
You may use RadListViewDataItem GetDataKeyValue method:
protected
void
RadListView1_ItemDataBound(
object
sender, Telerik.Web.UI.RadListViewItemEventArgs e)
{
var dataItem = e.Item
as
RadListViewDataItem;
if
(dataItem !=
null
)
{
//MyDataKeyName should be declared through RadListView's DataKeyNames property
var value = (
int
)dataItem.GetDataKeyValue(
"MyDataKeyName"
);
}
}
Regards,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
James
Top achievements
Rank 1
answered on 08 Sep 2010, 01:56 PM
Thanks a lot, that's just what i needed.. Really appreciate the help! :D
Just a case of finding all the new method names :-)
Just a case of finding all the new method names :-)