I have a RadListView and within the listview I have an asp.net linkbutton. I want to dynamically set the linkbutton's PostBackUrl. I can achieve this if I find the linkbutton control in the listview's ItemDataBound event. But by doing this when I end up clicking on the linkbutton the listview ItemCommand event is not being fired. I need the itemCommand event to be fired so I can take the datakeyvalue of the item clicked and set it into a session variable to pass to the postbackurl page of the link button, but setting the postbackurl when the page loads causes the linkbutton not to fire any events.
<telerik:RadListView ID="lstVwWebpageList" runat="server" EnableViewState="true" ItemPlaceholderID="webpageContainer" AllowPaging="true" DataKeyNames="id" Skin="WebBlue" OnItemDataBound="lstVwWebpageList_ItemDataBound" OnPageIndexChanged="lstVwWebpageList_PageChange" Width="607px" OnItemCommand="lstVwWebpageList_ItemCommand">
<LayoutTemplate>
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:PlaceHolder ID="webpageContainer" runat="server" />
</td>
</tr>
<tr>
<td>
<telerik:RadDataPager ID="Pager" runat="server" PagedControlID="lstVwWebpageList" PageSize="50" Skin="WebBlue">
<Fields>
<telerik:RadDataPagerButtonField FieldType="FirstPrev" />
<telerik:RadDataPagerButtonField FieldType="Numeric" />
<telerik:RadDataPagerButtonField FieldType="NextLast" />
</Fields>
</telerik:RadDataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<fieldset style="float: left; width: 300px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="width: 25%;">
<b>Name:</b>
</td>
<td style="width: 75%;">
<asp:Label ID="lblName" runat="server" Text='<%# Eval("name") %>'></asp:Label>
</td>
</tr>
<tr>
<td style="width: 25%;">
<b>Page:</b>
</td>
<td style="width: 75%;">
<asp:LinkButton ID="pagenameLink" runat="server" OnClick="test" OnCommand="testing" CommandName="LinkClicked" Text='<%# Eval("pagename") %>' PostBackUrl='<%# "EditWebpage.aspx?name=" + Eval("name") + "&page=" + Eval("pagename") %>'></asp:LinkButton>
</td>
</tr>
</table>
</td>
</tr>
</table>
</fieldset>
</ItemTemplate>
protected void lstVwWebpageList_ItemCommand(object sender, RadListViewCommandEventArgs e)
{
if (e.CommandName == "LinkClicked")
{
RadListViewDataItem item = (RadListViewDataItem)e.ListViewItem;
Session["linkID"] = item.DataItem;
}
}
try this