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

RadComboBox in RadTooltipManager

3 Answers 83 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Alexey
Top achievements
Rank 1
Alexey asked on 12 Jul 2011, 02:47 PM
Hi All,

I have a problem with RadComboBox and setting SelectedIndex value.

My controls structure are next:

<telerik:RadToolTipManager ID="editRecordTooltip" ShowEvent="OnClick" OffsetY="-1" HideEvent="ManualClose" Modal="true"
    Width="470" Height="390" runat="server" EnableShadow="true" OnAjaxUpdate="OnAjaxUpdate" RelativeTo="Element"
    Position="MiddleRight">                                
</telerik:RadToolTipManager>
 
<telerik:RadGrid ID="rgRecords" AutoGenerateColumns="false" runat="server" OnItemDataBound="rgRecords_ItemDataBound">
    <MasterTableView DataKeyNames="ID">
        <Columns>
.....
         </Columns>
    </MasterTableView>
</telerik:RadGrid>


 protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args)
 {
     UpdateToolTip(args.Value, args.UpdatePanel);
 }
private void UpdateToolTip(string elementId, UpdatePanel panel)
{            
   Control ctrl = Page.LoadControl("EditRecord.ascx");
   panel.ContentTemplateContainer.Controls.Add(ctrl);
}

protected void rgRecords_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                var target = e.Item.FindControl("hlEdit");
                editRecordTooltip.TargetControls.Add(target.ClientID, (e.Item as GridDataItem).GetDataKeyValue("ID").ToString(), true);
            }
        }

EditRecord.ascx contains:

<telerik:RadComboBox runat="server" ID="rcbCompany" Filter="Contains" ZIndex="50001" Width="234px" CssClass="select-text" />
protected override void OnPreRender(EventArgs e)
{
   base.OnPreRender(e);
   
   
   rcbCompany.DataSource = Source;
   rcbCompany.DataValueField = "ID";
   rcbCompany.DataTextField = "Name";
   rcbCompany.DataBind();
rcbCompany.SelectedIndex = 10; // for example
   this.DataBind();
}
When I set rcbCompany.SelectedIndex = 10, it does not worked.
On front-end selectedindex is always -1.

But, standart DropDownList worked perfectly.

How I can set SelectedIndex?

Thanks

3 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 15 Jul 2011, 01:30 PM
Hello Alexey,

Please try removing the this.DataBind() method invocation from your code and let us know the result:
rcbCompany.DataSource = CreateDataSource();
rcbCompany.DataValueField = "ID";
rcbCompany.DataTextField = "Name";
rcbCompany.DataBind();
 
rcbCompany.SelectedIndex = 10; // for example
 
//this.DataBind();

All the best,
Kalina
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Alexey
Top achievements
Rank 1
answered on 15 Jul 2011, 01:50 PM
Hi Kalina,

>Please try removing the this.DataBind() method invocation from your code and let us know the result

It's worked, but with the bug.

rcbCompany.DataSource = CreateDataSource();
rcbCompany.DataValueField = "ID";
rcbCompany.DataTextField = "Name";
rcbCompany.DataBind();

if (somevalue) 
   rcbCompany.SelectedIndex = 10; // for example
 
I have a grid with several records, where somevalue=true or somevalue=false.
In this case when I open tooltip with somevalue=true it's worked, but when I open tooltip with somevalue=false, after 
tooltip with somevalue=true, than rcbCompany.SelectedIndex == 10 on front-end, but should be == -1.

When I try this solution:

rcbCompany.DataSource = CreateDataSource();
rcbCompany.DataValueField = "ID";
rcbCompany.DataTextField = "Name";
rcbCompany.DataBind();

this.DataBind();

if (somevalue) 
   rcbCompany.SelectedIndex = 10; // for example

All worked perfectly.
0
Kalina
Telerik team
answered on 19 Jul 2011, 01:37 PM
Hi Alexey,

Glad that you managed to find a solution.
Feel free to contact us if you need additional assistance.

All the best,
Kalina
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Ajax
Asked by
Alexey
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Alexey
Top achievements
Rank 1
Share this question
or