I have RadGrid in which I need to only bind a UserControl in Item_Created Event,when the I try to expand the NestedViewTemplate.
Right now,it is also binding the UserControl even when the I bind the RadGrid.
Is there a property to identify if the NestViewTemplate is Expand,like how when have it in GridEditFormItem,where we say e.Item.IsInEditMode.
<telerik:RadGrid ID="radGridQuestionnaire" runat="server"
Width="100%"
PageSize="20"
AutoGenerateColumns="False"
GridLines="None"
AllowSorting="True"
AllowPaging="True"
OnNeedDataSource="radGridQuestionnaire_NeedDataSource"
OnItemCreated="radGridQuestionnaire_ItemCreated"
OnItemDataBound="radGridQuestionnaire_ItemDataBound"
OnItemCommand="radGridQuestionnaire_ItemCommand">
<PagerStyle Mode="NextPrevNumericAndAdvanced"/>
<MasterTableView EnableViewState="true" DataKeyNames="Form.DisplayFormName,Question.QuestionNumber,Question.QuestionId,ReviewId" Width="100%">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn HeaderText="Form" UniqueName="FormName" DataField="Form.DisplayFormName" HeaderStyle-Width="40%" />
<telerik:GridBoundColumn HeaderText="Question #" UniqueName="QuestionNumber" DataField="Question.QuestionNumber" HeaderStyle-Width="15%" />
<telerik:GridBoundColumn HeaderText="Status" UniqueName="QuestionnaireStatusName" DataField="QuestionnaireStatus.QuestionnaireStatusName" HeaderStyle-Width="15%" />
<telerik:GridBoundColumn HeaderText="Submitted By" UniqueName="SubmittedBy" DataField="Questionnaire.SubmittedBy" HeaderStyle-Width="15%" />
<telerik:GridBoundColumn HeaderText="Submitted On" UniqueName="SubmittedOn" DataField="Questionnaire.SubmittedOn" HeaderStyle-Width="15%" />
</Columns>
<NestedViewTemplate>
<div id="divChoiceMain" class="pad10">
<div class="divChoiceTextSection">
<div class="divChoiceTextLeftSection">Form:</div>
<div class="divFloatLeft">
<asp:Label ID="lblFormName" runat="server" Text='<%# Eval("Form.DisplayFormName")%>'/>
</div>
</div>
<div class="divChoiceTextSection">
<div class="divChoiceTextLeftSection">Question #:</div>
<div class="divFloatLeft">
<div>
<asp:Label ID="lblQuestionNumber" runat="server" Text='<%#Eval("Question.QuestionNumber")%>'/>
</div>
</div>
</div>
<div class="divChoiceTextCorrectiveActionSection">
<div class="divFloatLeft padtop5" style="margin-left:100px;">
<ar:ReviewConfigurationToolTipUC ID="reviewConfigurationToolTipUC" runat="server" />
</div>
</div>
</div>
<div class="clearfix pad10">
<div class="divChoiceTextSection">
<div class="divFloatLeft padRight10">
<asp:LinkButton ID="lnkBtnSave" runat="server" Text="Save" CommandName="Save" CommandArgument='<%#Eval("Question.QuestionId")%>'></asp:LinkButton>
</div>
<div class="divFloatLeft padRight10">
<asp:LinkButton ID="lnkSaveAndSubmit" runat="server" Text="Save & Submit" CommandName="Submit" CommandArgument='<%#Eval("Question.QuestionId")%>'></asp:LinkButton>
</div>
<div class="divFloatLeft">
<asp:LinkButton ID="lnkBtnCancel" runat="server" Text="Cancel" CommandName="Cancel"></asp:LinkButton>
</div>
</div>
</div>
</NestedViewTemplate>
</MasterTableView>
</telerik:RadGrid>
protected void radGridQuestionnaire_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridNestedViewItem)
{
GridNestedViewItem gridNestedViewItemObj = e.Item as GridNestedViewItem;
if (gridNestedViewItemObj == null)
{
return;
}
if (gridNestedViewItemObj.OwnerTableView.DataKeyValues != null)
{
int? questionId = gridNestedViewItemObj.OwnerTableView.DataKeyValues[0]["Question.QuestionId"].ToNullableInt32();
if (questionId.HasValue)
{
ReviewConfigurationToolTipUC reviewConfigurationToolTipUCObj = gridNestedViewItemObj.FindControl("reviewConfigurationToolTipUC") as ReviewConfigurationToolTipUC;
if (reviewConfigurationToolTipUCObj != null)
{
//Create FormQuestion Obj.
FormQuestion formQuestionObj = new FormQuestion { QuestionId = questionId };
reviewConfigurationToolTipUCObj.BuildToolTip(string.Empty, formQuestionObj, null);
}
}
}
}
}
Right now,it is also binding the UserControl even when the I bind the RadGrid.
Is there a property to identify if the NestViewTemplate is Expand,like how when have it in GridEditFormItem,where we say e.Item.IsInEditMode.
<telerik:RadGrid ID="radGridQuestionnaire" runat="server"
Width="100%"
PageSize="20"
AutoGenerateColumns="False"
GridLines="None"
AllowSorting="True"
AllowPaging="True"
OnNeedDataSource="radGridQuestionnaire_NeedDataSource"
OnItemCreated="radGridQuestionnaire_ItemCreated"
OnItemDataBound="radGridQuestionnaire_ItemDataBound"
OnItemCommand="radGridQuestionnaire_ItemCommand">
<PagerStyle Mode="NextPrevNumericAndAdvanced"/>
<MasterTableView EnableViewState="true" DataKeyNames="Form.DisplayFormName,Question.QuestionNumber,Question.QuestionId,ReviewId" Width="100%">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn HeaderText="Form" UniqueName="FormName" DataField="Form.DisplayFormName" HeaderStyle-Width="40%" />
<telerik:GridBoundColumn HeaderText="Question #" UniqueName="QuestionNumber" DataField="Question.QuestionNumber" HeaderStyle-Width="15%" />
<telerik:GridBoundColumn HeaderText="Status" UniqueName="QuestionnaireStatusName" DataField="QuestionnaireStatus.QuestionnaireStatusName" HeaderStyle-Width="15%" />
<telerik:GridBoundColumn HeaderText="Submitted By" UniqueName="SubmittedBy" DataField="Questionnaire.SubmittedBy" HeaderStyle-Width="15%" />
<telerik:GridBoundColumn HeaderText="Submitted On" UniqueName="SubmittedOn" DataField="Questionnaire.SubmittedOn" HeaderStyle-Width="15%" />
</Columns>
<NestedViewTemplate>
<div id="divChoiceMain" class="pad10">
<div class="divChoiceTextSection">
<div class="divChoiceTextLeftSection">Form:</div>
<div class="divFloatLeft">
<asp:Label ID="lblFormName" runat="server" Text='<%# Eval("Form.DisplayFormName")%>'/>
</div>
</div>
<div class="divChoiceTextSection">
<div class="divChoiceTextLeftSection">Question #:</div>
<div class="divFloatLeft">
<div>
<asp:Label ID="lblQuestionNumber" runat="server" Text='<%#Eval("Question.QuestionNumber")%>'/>
</div>
</div>
</div>
<div class="divChoiceTextCorrectiveActionSection">
<div class="divFloatLeft padtop5" style="margin-left:100px;">
<ar:ReviewConfigurationToolTipUC ID="reviewConfigurationToolTipUC" runat="server" />
</div>
</div>
</div>
<div class="clearfix pad10">
<div class="divChoiceTextSection">
<div class="divFloatLeft padRight10">
<asp:LinkButton ID="lnkBtnSave" runat="server" Text="Save" CommandName="Save" CommandArgument='<%#Eval("Question.QuestionId")%>'></asp:LinkButton>
</div>
<div class="divFloatLeft padRight10">
<asp:LinkButton ID="lnkSaveAndSubmit" runat="server" Text="Save & Submit" CommandName="Submit" CommandArgument='<%#Eval("Question.QuestionId")%>'></asp:LinkButton>
</div>
<div class="divFloatLeft">
<asp:LinkButton ID="lnkBtnCancel" runat="server" Text="Cancel" CommandName="Cancel"></asp:LinkButton>
</div>
</div>
</div>
</NestedViewTemplate>
</MasterTableView>
</telerik:RadGrid>
protected void radGridQuestionnaire_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridNestedViewItem)
{
GridNestedViewItem gridNestedViewItemObj = e.Item as GridNestedViewItem;
if (gridNestedViewItemObj == null)
{
return;
}
if (gridNestedViewItemObj.OwnerTableView.DataKeyValues != null)
{
int? questionId = gridNestedViewItemObj.OwnerTableView.DataKeyValues[0]["Question.QuestionId"].ToNullableInt32();
if (questionId.HasValue)
{
ReviewConfigurationToolTipUC reviewConfigurationToolTipUCObj = gridNestedViewItemObj.FindControl("reviewConfigurationToolTipUC") as ReviewConfigurationToolTipUC;
if (reviewConfigurationToolTipUCObj != null)
{
//Create FormQuestion Obj.
FormQuestion formQuestionObj = new FormQuestion { QuestionId = questionId };
reviewConfigurationToolTipUCObj.BuildToolTip(string.Empty, formQuestionObj, null);
}
}
}
}
}