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

Confirm before delete

5 Answers 199 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 17 May 2011, 04:00 PM
Hi,

I'm using a grid and I followed this demo to make a context menu wich allow to add, edit or delete a user. The problem is that I want that a confirm window appears when I click on the delete item. So, I used a WindowManger.RadConfirm(), wich call a JS function. There, I verified if the paramater is true or false. If true, so it mean the user click on okay and then, with a ajaxRequest, I call a function in the code-behind who delete the user. Everything will be just find, if it wasn't for just one thing : the grid isn't automatically update and the user stay in the list even after it is delete. I had to close my window and open it again to show my grid with the correct data. I tried to do a dataRebind, but it doesn't work. Can someone tell me what to do to refresh my grid. Thanks !!!    

David

5 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 18 May 2011, 07:49 PM
Nobody have any ideas ?
0
Vasil
Telerik team
answered on 20 May 2011, 01:13 PM
Hi David,

If you use Simple Data Binding, you will have set the new data source, and then call DataBind(); Only calling DataBind() will not do the trick if you don't change the DataSource.
If you use Advanced Data Binding you will need to call Rebind();

Also make sure that the grid is set to be updated control in your Ajax settings. Otherwise it will not be updated after the callback, even that you have rebind it server side.

Best wishes,
Vasil
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 20 May 2011, 03:17 PM
Hi

Thank you for you answer, it seem close to work, but there are still some problems. First of all, I'm not very familiar with the Ajax thing. I followed the tuto and then tried to adapt it to my case. There is what it give :

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="MyGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="MyGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

Is it okay ?

The second points I'm not sure is the part about the Advanced Data Binding vs the Simple Data Binding. What's the difference between them. If it could help, I make my grid in the client side. Here's my code.

<telerik:RadGrid ID="MyGrid" runat="server" Height="415px"
        DataSourceID="SqlDataSource1" width="514px"
        AllowSorting="True" AllowAutomaticDeletes="True"
        GridLines="None">
    <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
        <CommandItemSettings ExportToPdfText="Export to PDF" />
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn DataField="Column1" HeaderText="Column 1"
                    SortExpression="Column1" UniqueName="Column1">
            </telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <ClientSettings>
        <ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents>
        <Selecting AllowRowSelect="True"></Selecting>
        <Scrolling AllowScroll="True" UseStaticHeaders="True" ScrollHeight="100%"></Scrolling>
    </ClientSettings>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
    </HeaderContextMenu>
</telerik:RadGrid>


<asp:SqlDataSource runat="server" ID="SqlDataSource1"
        SelectCommand="SELECT [Column1] FROM [Table1]"
        DeleteCommand="DELETE FROM [Table1] WHERE [Column1] = @Column1"
        ConnectionString="<%$ ConnectionStrings:aspNet %>">
    <DeleteParameters>
      <asp:Parameter Name="Column1" />
    </DeleteParameters>
</asp:SqlDataSource>


My last and biggest problem is the following : when I tried to do a DataBind or Rebind, my debugger tell  me that :"Both DataSource and DataSourceID are defined on 'ctl00'.  Remove one definition."

Seem like it doesn't like that I try to change my dataSource. Thank you in advance for your answer.
0
Vasil
Telerik team
answered on 24 May 2011, 01:50 PM
Hello David,

In your current settings, the grid update itself, but firing an ajaxRequest will not update the grid. So your grid is updating on server side, but its rendered HTML is not sent from the server to the browser.

You should add such an Ajax setting, that will retrieve updated grid to the browser during the Ajax call.

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="MyGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="MyGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="MyGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

I see that you are using declarativelly binded grid, in such a case you don't need to rebind the grid. It will rebind automatically after the delete operation.

See these resources for more information about ajaxifying controls:
http://www.telerik.com/help/aspnet-ajax/ajax-ajaxmanager.html
http://www.telerik.com/help/aspnet-ajax/ajax-radajaxmanager-client-object.html

Greetings,
Vasil
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 24 May 2011, 04:36 PM
Hi

Thanks, it works perfectly
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or