This is a migrated thread and some comments may be shown as answers.

Pre-select RadComboBox when page loads

3 Answers 227 Views
Grid
This is a migrated thread and some comments may be shown as answers.
aks
Top achievements
Rank 1
aks asked on 16 Jul 2012, 08:13 PM
I have a RadGrid with some columns using filtering.  The filters are RadComboBox and I need to pre-select a value in the combo box when the page loads using a QueryString value I am passing in.  Here is my ASPX code.  Please help, how do I get my filter preselected to the value I am passing in.

QueryString:
Request.QueryString["AssigneeFullName"]

ASPX:
<telerik:GridTemplateColumn DataField="AssigneeFullName" HeaderText="Assignee" UniqueName="AssigneeFullName"
SortExpression="AssigneeFullName" HeaderStyle-Width="130px">
<ItemTemplate>
<asp:Label ID="lblAssigneeFullName" runat="server" Text='<%#Eval("AssigneeFullName")%>'></asp:Label>
</ItemTemplate>
<HeaderStyle Font-Bold="True" Width="130px" HorizontalAlign="Center" Font-Names="Arial" />
<FilterTemplate>
<telerik:RadComboBox ID="RadComboBoxTitle" DataTextField="FullName" DataValueField="FullName"
OnSelectedIndexChanged="RadComboAssignee_SelectedIndexChanged" AppendDataBoundItems="true"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("AssigneeFullName").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="AssigneeIndexChanged" Width="120px"
DataSource="<%# ComboBoxAssignees() %>">
<Items>
<telerik:RadComboBoxItem Text="View All" Value="" />
</Items>
</telerik:RadComboBox>
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

<script type="text/javascript">
function AssigneeIndexChanged(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("AssigneeFullName", args.get_item().get_value(), "EqualTo");
}
</script>

</telerik:RadScriptBlock>
</FilterTemplate>
</telerik:GridTemplateColumn>

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 17 Jul 2012, 12:57 PM
Hello,

You can pass the query string using the following code.
C#:
string data = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
  data = Request.QueryString["AssigneeFullName"];
}
protected void rad_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
  if (e.Item is GridFilteringItem)
  {
    GridFilteringItem item = (GridFilteringItem)e.Item;
    RadComboBox combo = (RadComboBox)item.FindControl("RadComboBoxTitle");
    combo.SelectedItem.Text = data;
  }
}

Thanks,
Shinu.
0
BChq
Top achievements
Rank 1
answered on 06 Sep 2012, 11:31 AM
Hi ,

I need to show the all selected items during form edit in radcombo .

lets say if i have 10 item in my combo out of which i have selected 5 .

when i edit same form i want those items to be selected and remaining as not selected.

How do i do it 

Regards
BCHQ
0
Eyup
Telerik team
answered on 10 Sep 2012, 02:11 PM
Hello,

I am afraid it is quite difficult to figure out your exact requirement by the provided information so far. Could you please elaborate some more on the issue? It would be great if you provide us some screenshots of the desired behavior.

All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
aks
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
BChq
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or