0
第一期,我在我的頁面上有兩個控件(一個radcombox和一個Treelist控件)。在radcombobox的SelectedIndexChanged上,我從數據庫填充數據。現在我想在SelectedIndexChanged上激發NeedDatasource事件。我怎麼能這樣做?以編程方式與NeedDatasource綁定?
第二個問題
由於我面臨着needdatasource一些問題,我一直在使用數據綁定radtreelist.After的方法手動綁定綁定它只顯示父節點在第一。
點擊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;
}
結合後,它僅示出了父數據。