I am trying to add a listview inside another listview itemtemplate. parent listview has openaccesslinqdatasource. inner listview has onneeddatasource. But i cant access any control custom attribute or parent GetDataKeyValue . There is old post here about it but no result avery time give me null. Thank you.
basic structure.
***************---------------***************
<telerik:RadAjaxPanel ID="apCevapList" runat="server"
ViewStateMode="Enabled"
EnableViewState="true">
<telerik:RadListView ID="lvParent" runat="server"
DataKeyNames="CId"
DataSourceID="OADLSParent"
ViewStateMode="Enabled"
EnableViewState="true"
Skin="MetroTouch">
<ItemTemplate>
<asp:HiddenField ID="hfCid2" runat="server" Value='<%# Eval("CId") %>' />
<telerik:RadAjaxPanel ID="apCevapYorum" runat="server"
ViewStateMode="Enabled" EnableViewState="true">
<telerik:RadListView ID="lvChild" runat="server"
DataKeyNames="Id"
EnableViewState="true"
ViewStateMode="Enabled"
InsertItemPosition="FirstItem"
AllowPaging="True"
PageSize="5"
Skin="Transparent"
OnNeedDataSource="lvChild_NeedDataSource"
OnItemCommand="lvChild_ItemCommand">
<ValidationSettings CommandsToValidate="PerformInsert"
ValidationGroup="insertGroup"
EnableValidation="true"></ValidationSettings>
</telerik:RadListView>
</telerik:RadAjaxPanel>
</ItemTemplate>
</telerik:RadListView>
</telerik:RadAjaxPanel>
***************---------------***************
Code behind something like that:
***************---------------***************
protected void lvChild_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
{
RadListView lvChild = (RadListView)sender;
RadListViewDataItem parentItem = (RadListViewDataItem)lvChild.NamingContainer;
var parentDatakeyId = (int)parentItem.GetDataKeyValue("CId"); //This give me null exception
//OR
// this button is in itemtemplate of parent with custom attribute cId= '<%# Eval("CId") %>'
RadButton rb = (RadButton)parentItem.FindControl("btnShowChildLvInsertItem");
int cId = Convert.ToInt32(rb.Attributes["cId"]);//null
//OR
HiddenField hf = (HiddenField)parentItem.FindControl("hfCId");
string cId2 = hf.Value;//null
***************---------------***************
i can Access all cid value or other values in itemcommand event of child lv. but there is a problem at needdatasource event of child listview. all cid null.
Thank you.
basic structure.
***************---------------***************
<telerik:RadAjaxPanel ID="apCevapList" runat="server"
ViewStateMode="Enabled"
EnableViewState="true">
<telerik:RadListView ID="lvParent" runat="server"
DataKeyNames="CId"
DataSourceID="OADLSParent"
ViewStateMode="Enabled"
EnableViewState="true"
Skin="MetroTouch">
<ItemTemplate>
<asp:HiddenField ID="hfCid2" runat="server" Value='<%# Eval("CId") %>' />
<telerik:RadAjaxPanel ID="apCevapYorum" runat="server"
ViewStateMode="Enabled" EnableViewState="true">
<telerik:RadListView ID="lvChild" runat="server"
DataKeyNames="Id"
EnableViewState="true"
ViewStateMode="Enabled"
InsertItemPosition="FirstItem"
AllowPaging="True"
PageSize="5"
Skin="Transparent"
OnNeedDataSource="lvChild_NeedDataSource"
OnItemCommand="lvChild_ItemCommand">
<ValidationSettings CommandsToValidate="PerformInsert"
ValidationGroup="insertGroup"
EnableValidation="true"></ValidationSettings>
</telerik:RadListView>
</telerik:RadAjaxPanel>
</ItemTemplate>
</telerik:RadListView>
</telerik:RadAjaxPanel>
***************---------------***************
Code behind something like that:
***************---------------***************
protected void lvChild_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
{
RadListView lvChild = (RadListView)sender;
RadListViewDataItem parentItem = (RadListViewDataItem)lvChild.NamingContainer;
var parentDatakeyId = (int)parentItem.GetDataKeyValue("CId"); //This give me null exception
//OR
// this button is in itemtemplate of parent with custom attribute cId= '<%# Eval("CId") %>'
RadButton rb = (RadButton)parentItem.FindControl("btnShowChildLvInsertItem");
int cId = Convert.ToInt32(rb.Attributes["cId"]);//null
//OR
HiddenField hf = (HiddenField)parentItem.FindControl("hfCId");
string cId2 = hf.Value;//null
***************---------------***************
i can Access all cid value or other values in itemcommand event of child lv. but there is a problem at needdatasource event of child listview. all cid null.
Thank you.