I have a button inside a user web control (.ascx) that does the postback. I would like the grid to refresh on the postback of the button click. Therefore, I refresh the grid in the aspx’s Page_Load:
if (IsPostBack)
Grid1.Rebind();
I also added validateRequest="false" EnableEventValidation="false" to <%@ Page%> to supress the invalid postback exception. This did refresh my grid on the web control button click postback. However, when I put the grid item in edit mode, none of the events in the edit form was fired, such as button click or combo’s selection change. I am guessing this is because Grid1.Rebind(); in Page_Load cause ItemDataBound event raised when an event was fired in the edit form. Here is my ItemDataBound handler:
protected void Grid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
MyCombo combo = editedItem.FindControl("myCombo") as MyCombo;
combo.UserName = UserName;
combo.DataBind();
}
}
Please help. Thanks,
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
|
<telerik:RadGrid ID="rgBizTypePercent" runat="server" Skin="Vista"
AutoGenerateColumns="False" DataSourceID="sdsBizTypePercentages"
AllowAutomaticInserts="true"
GridLines="None">
<HeaderContextMenu>
<CollapseAnimation Duration="200" Type="OutQuint" />
</HeaderContextMenu>
<MasterTableView EditMode="InPlace" DataKeyNames="ID"
CommandItemDisplay="Top" DataSourceID="sdsBizTypePercentages">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" Display="true"
Visible="true">
</telerik:GridEditCommandColumn>
<telerik:GridDropDownColumn DataSourceID="sdsBizType"
HeaderText="Business Type" ListTextField="Description"
ListValueField="BusinessTypeID" DataType="System.Int32"
UniqueName="BusinessTypeID">
</telerik:GridDropDownColumn>
<telerik:GridDropDownColumn DataSourceID="sdsPercent"
HeaderText="Business Percent" ListTextField="perc"
ListValueField="id" DataType="System.Int32"
UniqueName="Amount">
</telerik:GridDropDownColumn>
</Columns>
<EditFormSettings>
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu>
<CollapseAnimation Duration="200" Type="OutQuint" />
</FilterMenu>
</telerik:RadGrid>
<asp:SqlDataSource ID="sdsBizTypePercentages" runat="server"
ConnectionString="<%$ ConnectionStrings:BROKERConnectionString %>"
SelectCommand="SELECT * FROM [ProducerBusinessType]"
DeleteCommand="DELETE FROM [ProducerBusinessType] WHERE [ProducerID] = @ProducerID AND [BusinessTypeID] = @BusinessTypeID"
InsertCommand="INSERT INTO [ProducerBusinessType] ([ProducerID], [BusinessTypeID], [Amount]) VALUES (@ProducerID, @BusinessTypeID, @Amount)"
UpdateCommand="UPDATE [ProducerBusinessType] SET [ID] = @ID, [Amount] = @Amount WHERE [ProducerID] = @ProducerID AND [BusinessTypeID] = @BusinessTypeID">
<InsertParameters>
<asp:SessionParameter Name="ProducerID" DefaultValue="100000" SessionField="ProducerID" Type="Int32" />
<%
--<asp:Parameter Name="ProducerID" Type="Int32" />--%>
<asp:FormParameter FormField="BusinessTypeID" Name="BusinessTypeID" Type="Int32" />
<asp:FormParameter FormField="Amount" Name="Amount" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsPercent" runat="server"
ConnectionString="<%$ ConnectionStrings:BROKERConnectionString %>"
SelectCommand="SELECT * FROM [LookupPercent]"></asp:SqlDataSource>