第一个问题,我的页面上有两个控件(一个 radcombox 和一个 Treelist 控件)。在 radcombobox 的 SelectedIndexChanged 上,我正在从数据库中填充数据。现在我想在 SelectedIndexChanged 上触发 NeedDatasource 事件。我怎么能那样做?
第二题,
由于我遇到了需要数据源的一些问题,我已经使用 radtreelist 的数据绑定方法手动绑定。绑定后它首先只显示父节点。
单击 RadTreelist 的 PageSize 组合后,它会加载相应的子节点。为什么会发生这种情况?
<telerik:RadComboBox runat="server" ID="rcb_testtype" AutoPostBack="True" OnSelectedIndexChanged="rcb_testtype_OnSelectedIndexChanged">
<Items>
<telerik:RadComboBoxItem runat="server" Text="Select a Test Type" Value="-1" />
<telerik:RadComboBoxItem runat="server" Text="Practise Test" Value="pt" />
<telerik:RadComboBoxItem runat="server" Text="Normal Test" Value="nt" />
</Items>
</telerik:RadComboBox>
<telerik:RadTreeList ID="rtl_specific_topic" runat="server"
ParentDataKeyNames="parent_topicid" DataKeyNames="topicid" AllowPaging="true" RenderMode="Classic" Skin="WebBlue"
AutoGenerateColumns="false" AllowSorting="true" ExpandCollapseMode="Client" AllowRecursiveSelection="False" OnItemDataBound="rtl_specific_topic_OnItemDataBound"
AllowMultiItemSelection="true" OnItemCommand="RadTreeList1_ItemCommand" OnPageSizeChanged="RadTreeList1_PageSizeChanged" OnPageIndexChanged="RadTreeList1_PageIndexChanged">
<Columns>
<telerik:TreeListSelectColumn HeaderStyle-Width="38px">
</telerik:TreeListSelectColumn>
<telerik:TreeListBoundColumn DataField="parent_topicid" UniqueName="parent_topicid" HeaderText="Parent Topic Id" Visible="False">
</telerik:TreeListBoundColumn>
<telerik:TreeListBoundColumn DataField="topicid" UniqueName="topicid" HeaderText="Topic ID" Visible="False">
ion" UniqueName="description" HeaderText="Topic Name">
</telerik:TreeListBoundColumn>
<telerik:TreeListTemplateColumn HeaderText="Weightage" UniqueName="syllabus_weightage" HeaderStyle-Width="95px" ItemStyle-Width="95px">
<ItemTemplate>
<telerik:RadNumericTextBox runat="server" ID="rntb_weightage" MinValue="0" Width="80px" MaxValue="100" EmptyMessage="weightage(%)" AllowRounding="true"></telerik:RadNumericTextBox>
</ItemTemplate>
</telerik:TreeListTemplateColumn>
<telerik:TreeListTemplateColumn HeaderText="Weightage" UniqueName="quest_category">
<ItemTemplate>
<asp:DropDownList ID="ddl_quest_category" runat="server" Width="100px" style="right: 1px;">
<asp:ListItem Text="select a question type" Value="-1"></asp:ListItem>
<asp:ListItem Text="Multiple Choice" Value="1"></asp:ListItem>
<asp:ListItem Text="True/False" Value="2"></asp:ListItem>
<asp:ListItem Text="Essay Writing" Value="3"></asp:ListItem>
<asp:ListItem Text="Pictorial" Value="4"></asp:ListItem>
<asp:ListItem Text="Short Question" Value="5"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
<HeaderStyle Width="90px"></HeaderStyle>
</telerik:TreeListTemplateColumn>
<telerik:TreeListTemplateColumn HeaderText="Set Level" UniqueName="level">
<ItemTemplate>
<telerik:RadSlider runat="server" ID="rs_level" Skin="Web20" Width="490px" AutoPostBack="True"
Height="70px" CssClass="dragRangeSlider" EnableServerSideRendering="true" IsSelectionRangeEnabled="true" OnValueChanged="rs_level_OnValueChanged"
EnableDragRange="true"
ItemType="Item">
<Items>
<telerik:RadSliderItem Text="L1" Value="1" runat="server"></telerik:RadSliderItem>
<telerik:RadSliderItem Text="L2" Value="2" runat="server"></telerik:RadSliderItem>
</Items>
</telerik:RadSlider>
</ItemTemplate>
<HeaderStyle Width="490px"></HeaderStyle>
<ItemStyle Width="490px"></ItemStyle>
</telerik:TreeListTemplateColumn>
</Columns>
</telerik:RadTreeList>
OnSelectedIndexChanged 绑定 radtreelist
在后面的代码中
protected void rcb_testtype_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
rcb_syllabus_name.Visible = rcb_testtype.SelectedValue != "pt";
rtl_specific_topic.DataSource = FetchTopicDetailsForSyllabus();
rtl_specific_topic.DataBind();
}
private DataTable FetchTopicDetailsForSyllabus()
{
DataTable dtTopocsForTest = null;
if (rcb_testtype.SelectedValue == "nt" && rcb_syllabus_name.SelectedValue != "")
{
obj_BEL_LMS.Flag = "normaltest";
obj_BEL_LMS.Syllabusid = Convert.ToInt32(rcb_syllabus_name.SelectedValue);
dtTopocsForTest = obj_BL_LMS.FetchSyllabusDetails(obj_BEL_LMS);
}
else if (rcb_testtype.SelectedValue == "pt")
{
obj_BEL_LMS.iFlag = 2;
obj_BEL_LMS.iBranchId = Convert.ToInt32(Session["branchid"]);
dtTopocsForTest = obj_BL_LMS.FetchTopicDetailsDb(obj_BEL_LMS);
}
return dtTopocsForTest;
}
绑定后它只显示父数据。