This combo box is in an asp.net page and the intention is to bind it to a nvarchar(50).
The user select one of the values and then update the DB.
<telerik:RadComboBox ID="RadComboBox1" runat="server" SelectedValue='<%# Bind("inBudgetTT") %>'>
<Items>
<telerik:RadComboBoxItem Text="In Budget" />
<telerik:RadComboBoxItem Text="Not In Budget" />
</Items>
</telerik:RadComboBox>
The problem: doesn't matter what I select, it is never written in the DB. Any hint on how to solve the problem?
Use the SelectedIndexChanged event to update your database: http://www.telerik.com/help/aspnet-ajax/combobox-server-side-selectedindexchanged.html. The SelectedValue property only indicates what the control should show as a selected item.
Related
First Issue,I have two controls (a radcombox and a Treelist controls) on my page. On radcombobox's SelectedIndexChanged I am populating data from database.Now I want to fire NeedDatasource event on SelectedIndexChanged. How could I do that ?
Second issue,
As I am facing some issues with needdatasource, I have manually binded using databind method of radtreelist.After binding it shows only parent nodes at first.
After clicking on PageSize combo of RadTreelist, it loads with respective child nodes.Why is this happening here ?
<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 bind radtreelist
in Code behind
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;
}
After binding it shows only parent data.
From the Telerik documentation:
This event fires in the following cases:
Right after OnLoad, Telerik RadTreeList checks the viewstate for stored TreeList-related information. If such information is missing (when the page loads for the first time), the NeedDataSource event is fired. This also means that if the EnableViewState property of the control has been set to false, the treelist will bind each time the page loads (not only the first time)
After expand/collapse
When paging event occurs
When other operations requiring Rebind occurs
The advantages of using this event are that the developer does not need to write any code handling the logic about when and how the data-binding should be processed. It is still the developer's responsibility to construct properly a data source object and assign it to the RadTreeList's DataSource property.
In the code of the NeedDataSource handler you should prepare the data source (list of objects) for Telerik RadTreeList and assign it to the grid's DataSource property. Also you should set the DataKeyNames and ParentDataKeyNames propertied for the TreeList control.
Note: You should never call the DataBind() method from inside the NeedDataSource handler or mix simple data-binding mode with advanced data-binding
I suggest you edit your post and include your code.
I have a some controls inside an EditItemTemplate within a RadListView control:
<telerik:RadComboBox ID="cbCategoryTypeTueET" runat="server" Skin="Office2010Black"
SelectedValue='<%# DataBinder.Eval(Container.DataItem, "CategoryTypeID") %>'
TabIndex="1" Width="100%" EmptyMessage="--Select Category Type--" DataSourceID="edsCatTypeTueET"
DataTextField="CategoryName" DataValueField="CategoryTypeID" AutoPostBack="True"
OnSelectedIndexChanged="cbCategoryTypeTueET_SelectedIndexChanged" AccessKey="t" AppendDataBoundItems="True">
</telerik:RadComboBox>
<asp:EntityDataSource ID="edsCatTypeTueET" runat="server" ConnectionString=""
DefaultContainerName="ATITimeEntry" EnableFlattening="False" EntitySetName="TimeTrackingCategoryTypes"
Select="it.[CategoryTypeID], it.[CategoryName]"
Where="it.deletedFlag = false AND it.activeFlag = true" >
</asp:EntityDataSource>
The Entity datasource does have a connection string - I am using a new code generation template - so this is not an issue.
My problem is I want the combobox to bind on edit. But if activeFlag is false or deletedFlag is true (or both) the Radlistview will not go into edit mode. Is there an elegant way to do this with markup or some elegant query?
My understandig is, you want to forbid edit on some conditions.
You have to subscripe the ItemDataBound Event from the RadListView. There you can cast DataItem to your object and check the condition (Get Data being bound to ListView).
Then you can access your controls and manipulate them (like hide them)...
Conditionaly disable command button
I need to know the difference between a RadioButton and a RadioButtonList, and what are the guidelines to use when deciding which one to use?
I researched this and decided to post my findings here to help illustrate the differences I found that should help clarify my question:
What I Learned:
RadioButton
Used to display a single RadioButton at a time. Likely requires setting group attribute to associate multiple RadioButton controls into a group.
RadioButtonList
Used to Display a group of RadioButton controls, automatically providing the group attribute associating all the included RadioButton controls into a single group.
Observation
Visually, both produce the same result in the UI, provided one places at least 2 or more RadioButton controls on the page with the same value for the group attribute.
UI Sample Code follows
asp:RadioButton
<asp:RadioButton ID="b2b" text="B to B" checked="true" runat ="server" GroupName="businesstype" />
<asp:RadioButton ID="b2c" text="B to C" runat ="server" GroupName="businesstype" />
asp:RadioButtonList
<asp:RadioButtonList ID="businesstype" runat="server" >
<asp:ListItem Selected="True" Value="0">B to B</asp:ListItem>
<asp:ListItem Value="1">B to C</asp:ListItem>
</asp:RadioButtonList>
What are the guidelines for the use of each?
1. RadioButtonList
RadioButtonList is a single control with a list of RadioButtons.
This is derived from ListControl class. So this will work similar to other list controls like ListBox, DropDownList and CheckBoxList.
For giving a caption for buttons you can use the Text property. You cannot insert a text in between two buttons.
Using the “SelectedIndexChanged” event you will get the selected buttons value (“RadioButtonList1.SelectedValue”).
for e.g
private void Bind()
{
RadioButtonList1.DataSource = dsEmployees;
RadioButtonList1.DataTextField = "EmployeeName";
RadioButtonList1.DataValueField = "EmployeeID";
RadioButtonList1.DataBind();
}
If you are using HTML
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal"
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Text="Male" Value="1" ></asp:ListItem>
<asp:ListItem Text="Female" Value="2" ></asp:ListItem>
</asp:RadioButtonList>
2. RadioButton
RadioButton” is a single control, it is derived from “CheckBox” Class. You have to set the GroupName property to identify a group. Also the event handler for the event “CheckedChanged” will help us to do some job. Another one thing is you have to write separate handlers for each radio button.
For e.g.:
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="Gender"
AutoPostBack="true" oncheckedchanged="RadioButton1_CheckedChanged" Text="Male" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="Gender"
AutoPostBack="true" oncheckedchanged="RadioButton2_CheckedChanged" Text="Female" />
You can get the selected Index in RadioButtonList as it work on collection of ListItem.
You can visit here for more detail
In contrast, the RadioButtonList control is a single control that acts as a parent control for a collection of radio button list items.
It derives from a base ListControl Class, and therefore works much like the ListBox, DropDownList, and CheckBoxList Web server controls. Therefore, many of the procedures for working with the RadioButtonList control are the same as they are for the other list Web server controls.
An asp:radiobuttonlist creates a group of radiobuttons that ensures when one is selected, the others are deselected whereas asp:radiobutton is not within a group and therefore cannot be deselected by clicking other radio buttons.
I am making an ASPx and C# form with DevExpress comboboxes and an SQL database. I've pulled the data to one of the boxes that I need.
I need to assign a variable to one of the fields from the database that are pulled into the combobox.
<dx:ASPxComboBox ID="testNameBox" runat="server" CssClass="dropdown"
Font-Names="Tahoma" Font-Size="10px" ClientIDMode="AutoID"
DataSourceID="testSource" ValueType="System.String"
IncrementalFilteringMode="Contains">
<Columns>
<dx:ListBoxColumn FieldName="pkTestKey" Visible="False" />
<dx:ListBoxColumn FieldName="fkTestCode" Visible="False" />
<dx:ListBoxColumn Caption="Test Item Name" FieldName="Name" />
</Columns>
</dx:ASPxComboBox>
The point is that when I choose something in this combobox, another combobox displays related data from another table based on the fkCode value.
How would I pull that variable from this, and use it so that my query for the textbox displays the appropriate data based on that fkCode?
Take a look at this demo on DevExpress. You might want to search more about Cascading Comboboxes
<script>alert("demo for XSS")</script>
I have a combo box in a Form View and onchange i want to access a javascript function just as i'd normally do any drop down list. However, it doesn't seem to be even getting to the function
function Showused()
{
alert('eric');
}
<telerik:RadComboBox ID="RadComboBoxProvided" onchange="javascript: Showused();" runat="server" Width="50px" >
<Items>
<telerik:RadComboBoxItem runat="server" Text="Yes" Value="Y" />
<telerik:RadComboBoxItem runat="server" Text="No" Selected="true" Value="N" />
</Items>
</telerik:RadComboBox>
Simple javascript call. Any idea why this doesn't work?
The client-side event names are different for Telerik controls. The RadComboBox event for selected index changed (assuming you're using a recent version of the controls) is OnClientSelectedIndexChanged
You may want to consult the client-side programming guide for RadComboBox, or the list of client-side events.
Here's a sample for use with your example:
Javascript:
function SelectedIndexChanged(sender, eventArgs) {
var item = eventArgs.get_item();
alert("You selected " + item.get_text());
}
Markup:
<telerik:RadComboBox ID="RadComboBoxProvided" OnClientSelectedIndexChanged="SelectedIndexChanged" runat="server" Width="50px" >
<Items>
<telerik:RadComboBoxItem runat="server" Text="Yes" Value="Y" />
<telerik:RadComboBoxItem runat="server" Text="No" Selected="true" Value="N" />
</Items>
</telerik:RadComboBox>
is not a combo box, it is a custom tag, that will convert itself to an HTML combo box, to be sure what is happening there, run your server and go to that page, and then right click on the page in your browser and look at the HTML source, and finally try to locate that combo box and see how it is really rendered.