Hello,
My problem scenario:
I want to refresh second RadGrid after delete item from first RadGrid.
I tried use RadGridPrzedmiotyWydzialuBrakKatedry.Rebind()
in code behind in method: --- protected void RadGridPrzedmiotyWydzialu_DeleteCommand ---
but it doesn't work.
I hope for you help.
First RadGrid with SqlDataSource
Second RadGrid with SqlDataSource:
My problem scenario:
I want to refresh second RadGrid after delete item from first RadGrid.
I tried use RadGridPrzedmiotyWydzialuBrakKatedry.Rebind()
in code behind in method: --- protected void RadGridPrzedmiotyWydzialu_DeleteCommand ---
but it doesn't work.
protected void RadGridPrzedmiotyWydzialu_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e){ if (e.Item.Cells.Count > 0) { var db = DatabaseFactory.CreateDatabase(); var cmd = db.GetStoredProcCommand("katw_Przedmioty_Katedr_upd"); db.AddInParameter(cmd, "@idOsobaDziekan", DbType.Int32, MySession.IdOsoba); db.AddInParameter(cmd, "@idWydzial", DbType.Int32, MySession.IdWydzial); db.AddInParameter(cmd, "@idPrzedmiot", DbType.Int32, e.Item.Cells[2].Text); db.ExecuteNonQuery(cmd); }
//refresh my grid after delete item from first radgrid RadGridPrzedmiotyWydzialuBrakKatedry.Rebind(); }I hope for you help.
First RadGrid with SqlDataSource
<asp:SqlDataSource ID="SqlDataSourcePrzedmiotyWydzialu" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultDatabaseConnection %>" SelectCommand="katw_Przedmioty_Wydzialu_sel" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="WydzialRadComboBox" Name="IdWydzial" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters></asp:SqlDataSource><telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGridPrzedmiotyWydzialu"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGridPrzedmiotyWydzialu" LoadingPanelID="RadAjaxLoadingPanel" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGridPrzedmiotyWydzialuBrakKatedry"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGridPrzedmiotyWydzialuBrakKatedry" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManager><telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel" runat="server"></telerik:RadAjaxLoadingPanel><telerik:RadGrid ID="RadGridPrzedmiotyWydzialu" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellSpacing="0" Culture="pl-PL" GridLines="None" HorizontalAlign="Justify" Skin="Simple" OnDeleteCommand="RadGridPrzedmiotyWydzialu_DeleteCommand" DataSourceID="SqlDataSourcePrzedmiotyWydzialu"> <ClientSettings> <Selecting CellSelectionMode="None" AllowRowSelect="true" /> </ClientSettings> <MasterTableView NoMasterRecordsText="Brak rekordów do wyświetlenia." DataKeyNames="IdPrzedmiot" CommandItemDisplay="Top" DataSourceID="SqlDataSourcePrzedmiotyWydzialu"> <CommandItemSettings ExportToPdfText="Export to PDF" RefreshText="Odśwież" ShowAddNewRecordButton="False" /> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True"> <HeaderStyle Width="20px" /> </RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True"> <HeaderStyle Width="20px" /> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="IdPrzedmiot" HeaderText="IdPrzedmiot" UniqueName="IdPrzedmiot" FilterControlAltText="Filter IdPrzedmiot column" DataType="System.Int32" SortExpression="IdPrzedmiot" ReadOnly="true" Visible="false"> </telerik:GridBoundColumn> <telerik:GridButtonColumn CommandName="Edit" UniqueName="EditColumn" ButtonType="ImageButton" Text="Edytuj"> <HeaderStyle Width="3%" /> </telerik:GridButtonColumn> <telerik:GridButtonColumn CommandName="Delete" UniqueName="DeleteColumn" ButtonType="ImageButton" Text="Usuń"> <HeaderStyle Width="3%" /> </telerik:GridButtonColumn> <telerik:GridBoundColumn DataField="Nazwa" HeaderText="Nazwa przedmiotu" UniqueName="Nazwa" FilterControlAltText="Filter Nazwa column" DataType="System.String" SortExpression="Nazwa" ReadOnly="true"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Kod" HeaderText="Kod" UniqueName="Kod" FilterControlAltText="Filter Kod column" DataType="System.String" SortExpression="Kod" ReadOnly="true"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="IdKatedra" HeaderText="IdKatedra" UniqueName="IdKatedra" FilterControlAltText="Filter IdKatedra column" DataType="System.Int32" ReadOnly="true" Visible="false"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="KatedraNazwa" HeaderText="Katedra" UniqueName="Katedra" FilterControlAltText="Filter Katedra column" DataType="System.String" SortExpression="Katedra" ReadOnly="true"> </telerik:GridBoundColumn> </Columns> <EditFormSettings EditFormType="WebUserControl" UserControlName="PrzedmiotyKatedre.ascx"> <EditColumn FilterControlAltText="Filter EditCommandColumn column" ButtonType="ImageButton"> </EditColumn> </EditFormSettings> </MasterTableView></telerik:RadGrid>Second RadGrid with SqlDataSource:
<asp:SqlDataSource ID="SqlDataSourcePrzedmiotyWydzialuBrakKatedry" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultDatabaseConnection %>" SelectCommand="katw_Przedmioty_Wydzialu_BrakKatedry_sel" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="WydzialRadComboBox" Name="IdWydzial" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"> </telerik:RadAjaxLoadingPanel> <telerik:RadGrid ID="RadGridPrzedmiotyWydzialuBrakKatedry" runat="server" AllowPaging="true" AutoGenerateColumns="false" CellSpacing="0" Culture="pl-PL" DataSourceID="SqlDataSourcePrzedmiotyWydzialuBrakKatedry" GridLines="None" HorizontalAlign="Justify" Skin="Simple"> <ClientSettings> <Selecting CellSelectionMode="None" /> </ClientSettings> <MasterTableView DataSourceID="SqlDataSourcePrzedmiotyWydzialuBrakKatedry" NoMasterRecordsText="Brak rekordów do wyświetlenia." DataKeyNames="IdPrzedmiot" CommandItemDisplay="Top"> <CommandItemSettings ExportToPdfText="Export to PDF" RefreshText="Odśwież" ShowAddNewRecordButton="False" /> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True"> <HeaderStyle Width="20px" /> </RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True"> <HeaderStyle Width="20px" /> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="IdPrzedmiot" HeaderText="IdPrzedmiot" UniqueName="IdPrzedmiot" FilterControlAltText="Filter IdPrzedmiot column" DataType="System.Int32" SortExpression="IdPrzedmiot" ReadOnly="true" Visible="false"> </telerik:GridBoundColumn> <telerik:GridButtonColumn CommandName="Edit" Text="Edytuj" UniqueName="EditColumn" ButtonType="ImageButton"> <HeaderStyle Width="3%" /> </telerik:GridButtonColumn> <telerik:GridBoundColumn DataField="Nazwa" HeaderText="Nazwa przedmiotu" UniqueName="Nazwa" FilterControlAltText="Filter Nazwa column" DataType="System.String" SortExpression="Nazwa" ReadOnly="true"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Kod" HeaderText="Kod" UniqueName="Kod" FilterControlAltText="Filter Kod column" DataType="System.String" SortExpression="Kod" ReadOnly="true"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="IdKatedra" HeaderText="IdKatedra" UniqueName="IdKatedra" FilterControlAltText="Filter IdKatedra column" DataType="System.Int32" ReadOnly="true" Visible="false"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="KatedraNazwa" HeaderText="Katedra" UniqueName="Katedra" FilterControlAltText="Filter Katedra column" DataType="System.String" SortExpression="Katedra" ReadOnly="true"> </telerik:GridBoundColumn> </Columns> <EditFormSettings EditFormType="WebUserControl" UserControlName="PrzedmiotyKatedre.ascx"> <EditColumn FilterControlAltText="Filter EditCommandColumn column" ButtonType="ImageButton"> </EditColumn> </EditFormSettings> </MasterTableView> </telerik:RadGrid>