Hi,
I have two issues.
1. I have a RadComboBox whose selectedIndex to be reassigned at runtime based on some other actions on the page. Though I tried setting the ComboBox.SelectedIndex = some number, ComboBox.SelectedValue = some value - None of the ways I tried seem to work. The Combo.SelectedItem still stays as the old selected item. Does not change. What am I doing wrong?
2. I have three Image buttons in a CommandItemTemplate on my RadGrid. These buttons are "Editall", "UpdateAll" and "CancelAll".
Update and cancel button are initially hidden and the only button visible is Edit. These buttons are meant to make the grid
bulk-editable and bulk-updateable. I don't have any per row Command Items. All the columns are created at runtime. On inital page load, everything seem to be normal and I can only see the Edit button as expected. When I click the button, the Grid goes goes into Edit mode (I have the code in ItemCommand event handler). At this point I can only "see" the Update and Cancel buttons on the Command bar (again as expected). But the problem is nothing happens when I click on either the update button or the Cancel button. Seemingly, no event handlers get called. What am I doing wrong? I can give you a clue about the scenario. If I have all the three buttons visible on the initial page load, and I click the Update button, the ItemCommand event handler does get called. But none of the buttons fires any events on any subsequent page loads. So, I am thinking, there must be something wrong with my postbacks. Here is my code. Please tell me where all do I have to do the ReBind(). The code fragment is partial only.
My aspx file:
<telerik:RadGrid ID="rgForecast" runat="server" AllowSorting="True" AutoGenerateColumns="False"
ShowStatusBar="True" Width="800px" Skin="Forest" OnNeedDataSource="rgForecast_NeedDataSource"
OnPreRender="rgForecast_PreRender" GroupingEnabled="False" OnItemCommand="rgForecast_ItemCommand"
OnItemCreated="rgForecast_ItemCreated" AllowMultiRowEdit="True">
<MasterTableView CommandItemDisplay="Top" EditMode="InPlace">
<CommandItemTemplate>
<div id="EditButtonDiv" runat="server" style="position: relative; float: left;
padding-right: 20px;">
<asp:ImageButton ID="EditGrid" Text="Edit Items" AlternateText="Edit"
runat="server"
CommandName="EditAll" ImageUrl="~/Images/Edit.gif" ToolTip="Click to Edit
the Grid" />
</div>
<div id="UpdateButtonDiv" runat="server" style="position: relative; float: left;
padding-right: 20px;">
<asp:ImageButton ID="UpdateGrid" Text="Update Items" AlternateText="Update"
runat="server"
CommandName="UpdateAll" ImageUrl="~/Images/Update.gif" ToolTip="Click to
update the Grid" />
</div>
<div id="CancelButtonDiv" runat="server" style="position: relative; float: left;
padding-right: 20px;">
<asp:ImageButton ID="CancelUpdate" Text="Cancel Updates" AlternateText="Cancel"
runat="server"
CommandName="CancelAll" ImageUrl="~/Images/Cancel.gif" ToolTip="Click to
cancel updates" />
</div>
<div style="position: relative; float: right; padding-right: 20px;">
<asp:ImageButton ID="Export2Excel" Text="Export to Excel" AlternateText="Excel
Export" runat="server"
CommandName="ExportToExcel" ImageUrl="~/Images/MoveUp.gif" ToolTip="Click
to Export grid to Excel" />
</div>
</CommandItemTemplate>
</MasterTableView>
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<EditItemStyle BackColor="#FFFF99" />
<SortingSettings SortedAscToolTip="Sorted Asc" SortedDescToolTip="Sorted Desc" />
<StatusBarSettings LoadingText="Loading. Please wait....." />
</telerik:RadGrid>
My cs file:
protected void rgForecast_PreRender(object sender, EventArgs e)
{
RadGrid grid = (RadGrid)sender;
foreach (GridColumn col in grid.Columns)
{
if (Array.IndexOf(strInvisibleCols, col.UniqueName) >= 0)
col.Visible = false;
else
{
col.ItemStyle.Wrap = false;
col.HeaderStyle.Wrap = false;
}
}
//grid.Rebind();
}
protected void rgForecast_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "UpdateAll")
{UpdateGrid();}
else if (e.CommandName == "EditAll")
{EditGrid();}
else if (e.CommandName == "CancelAll")
{CancelUpdate();}
//rgForecast.Rebind();
}
protected void rgForecast_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridCommandItem)
{
GridCommandItem commandItem = e.Item as GridCommandItem;
ImageButton btnEdit = commandItem.FindControl("EditGrid") as ImageButton;
btnEdit.Visible = IsKeyerUser((string)Session[Role]) && rgForecast.EditIndexes.Count == 0;
ImageButton btnUpdate = commandItem.FindControl("UpdateGrid") as ImageButton;
btnUpdate.Visible = rgForecast.EditIndexes.Count > 0;
ImageButton btnCancel = commandItem.FindControl("CancelUpdate") as ImageButton;
btnCancel.Visible = rgForecast.EditIndexes.Count > 0;
}
}
Please help!!
Babu.