I have a RadGrid. Inside the CommandItemTemplate, I have a RadComboBox. What I am trying to do is when I select the different items in the RadComboBox, there is a RadToolTip that displays the information about the selected item. For ths I needed to do a postback with the SelectedIndexChanged event of the RadComboBox. Problem is when I select an item, the RadComboBox disappears.
Here is what I have for the RadGrid.
On the codebehind, I have
When the page loads, I can see the Location RadComboBox in the CommandItem. It has all the items loaded in it. But when I select an item in it, the ComboBox control disappears (only the combobox, other controls are fine.. I do have a RadAjaxManager whose initiate ControlId is RadGrid and update ControlId is itself.
Thank you.
Here is what I have for the RadGrid.
<rad:RadGrid ID="rgCustomer" runat="server" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="false" | |
OnItemCreated="rgCustomer_ItemCreated" OnItemCommand="rgCustomer_ItemCommand" Skin="Telerik" DataSourceID="odsCustomer"> | |
<PagerStyle Mode="NextPrevAndNumeric" /> | |
<ClientSettings EnableRowHoverStyle="true"> | |
<Selecting AllowRowSelect="true" /> | |
</ClientSettings> | |
<MasterTableView Width="100%" ShowFooter="false" DataKeyNames="CustomerId" CommandItemDisplay="Top"> | |
<CommandItemTemplate> | |
<div style="width:100%; margin:5px 5px 5px 5px;"> | |
<div style="width:10%; float:left; vertical-align:top; text-align:center;"> | |
Customer: | |
</div> | |
<div style="width:40%; float:left; vertical-align:top; text-align:center;"> | |
<div style="width:100%; text-align:center;"> | |
<rad:RadComboBox ID="rcbLocation" runat="server" Width="400px" Height="300px" MarkFirstMatch="true" | |
EnableLoadOnDemand="true" Skin="Telerik" AutoPostBack="true" OnSelectedIndexChanged="rcbLocation_SelectedIndexChanged" /> | |
<asp:RequiredFieldValidator ID="rfvLocation" runat="server" ControlToValidate="rcbLocation" Display="Dynamic" | |
SetFocusOnError="true" EnableClientScript="true" ErrorMessage="Required" InitialValue="0" ValidationGroup="save" /> | |
<rad:RadToolTip ID="rttLocation" runat="server" TargetControlID="rcbLocation" Sticky="true" Animation="Fade" | |
Position="MiddleRight" RelativeTo="Element" Skin="Telerik"> | |
<asp:Label ID="lblRttLocation" runat="server" /> | |
</rad:RadToolTip> | |
</div> | |
</div> | |
<div style="width:40%; float:left; vertical-align:top; text-align:center;"> | |
<rad:RadTextBox" ID="rtbCustomer" runat="server" Width="400px" Skin="Telerik" /> | |
<asp:RequiredFieldValidator ID="rfvCustomer" runat="server" ControlToVaidate"="rtbCustomer" Display="Dynamic" | |
SetFocusOnError="true" EnableClientScript="true" ErrorMessage="Required" ValidationGroup="save" /> | |
</div> | |
<div style="width:10%; float:left; vertical-align:top; text-align:center;"> | |
<asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" ValidationGroup="save" /> | |
</div> | |
</div> | |
</CommandItemTemplate> | |
<Columns> | |
<rad:GridBoundColumn HeaderText="Id" DataField="CustomerId" SortExpression="CustomerId" /> | |
<rad:GridBoundColumn HeaderText="Location" DataField="Location" SortExpresstion="Location" /> | |
<rad:GridBoundColumn HeaderText="Name" DataField="CustomerName" SortExpresstion="CustomerName" /> | |
</Columns> | |
</MasterTableView> | |
</rad:RadGrid> |
On the codebehind, I have
private Table gTable; |
private GridTHead gHead; |
private GridCommandItem gItem; |
protected void Page_Load(object sender, EventArgs e) |
{ |
if (!IsPostBack) |
{ |
rgCustomer.DataBind(); |
gTable = (Table)rgCustomer.MasterTableView.Controls[0]; |
gHead = (GridTHead)gTable.Controls[0]; |
gItem = (GridCommandItem)gHead.Controls[0]; |
RadComboBox rcb = (RadComboBox)gItem.FindControl("rcbLocation"); |
rcb.Items.Clear(); |
rcb.DataSource = LocationList.Search(null, null, null, null, null, null, null, null, null); |
rcb.DataTextField = "LocationName"; |
rcb.DataValueField = "LocationId"; |
rcb.DataBind(); |
rcb.Items.Insert(0, new RadComboBoxItem("Select", "0")); |
} |
} |
protected void rcbLocation_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) |
{ |
Label lbl = (Label)gItem.FindControl("lblRttLocation"); |
if (e.Value == "0") |
lbl.Text = "Select a Location"; |
else |
{ |
LocationList oLocation = LocationList.Get(Convert.ToInt32(e.Value)); |
lbl.Text = LocationList.LocationDetails; |
oLocation = null; |
} |
} |
When the page loads, I can see the Location RadComboBox in the CommandItem. It has all the items loaded in it. But when I select an item in it, the ComboBox control disappears (only the combobox, other controls are fine.. I do have a RadAjaxManager whose initiate ControlId is RadGrid and update ControlId is itself.
Thank you.