Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
224 views
I'm using the Batch Editing example as the basis of a page I'm doing.

It's ideal, because the users need to edit multiple rows and click save. The example does that with the Save Changes at the bottom. The down side is that I need to put in business logic on the create, update, and delete. Normally, I can do that, even with a SQLDataSource, using the SQLDataSource events (ex. PropertyHistories_Updating). The problem is that these events are not triggering.

Yes, I know that I could use Advanced Binding, but am unsure how this example would work with it.  :)
Any ideas?  (see attached)

Thanks,
Jason

Code:
BatchTest.aspx
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" HorizontalAlign="NotSet">
            <p>Hotel Name: <telerik:RadComboBox ID="HotelList" Width="500" runat="server" DataSourceID="Hotels" DataTextField="myview" 
                  AllowCustomText="false" Filter="StartsWith" ShowMoreResultsBox="true" DataValueField="Inncode" />
                <p>
                </p>
                <h3>Property History</h3>
                <telerik:RadGrid ID="PropertyHistory" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="PropertyHistories" OnBatchEditCommand="PropertyHistory_BatchEditCommand" OnItemDeleted="PersonnelHistory_ItemDeleted" OnItemInserted="PropertyHistory_ItemInserted" OnItemUpdated="PropertyHistory_ItemUpdated" OnPreRender="PropertyHistory_PreRender" Width="750px">
                    <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Bottom" DataKeyNames="RMCCHistoryID" DataSourceID="PropertyHistories" EditMode="Batch">
                        <BatchEditingSettings EditType="Row" OpenEditingEvent="Click" />
                        <SortExpressions>
                            <telerik:GridSortExpression FieldName="RMCCHistoryID" SortOrder="Descending" />
                        </SortExpressions>
                        <Columns>
                            <telerik:GridTemplateColumn DataField="Model" HeaderText="RMCC Support Model" UniqueName="Class">
                                <ItemTemplate>
                                    <%# Eval("Model") %>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadComboBox ID="RadComboBox1" runat="server" AllowCustomText="false" DataSourceID="Models" DataTextField="Model" EmptyMessage="Search Models" EnableAutomaticLoadOnDemand="true" Filter="StartsWith" Height="200px" ShowMoreResultsBox="true" />
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="Start Date" UniqueName="startdate">
                                <ItemTemplate>
                                    <asp:Label ID="date" runat="server" Text='<%# Eval("startdate") %>' />
                                    &nbsp;
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadDatePicker ID="picker1" runat="server" DbSelectedDate='<%# Bind("startdate") %>' MaxDate="12/31/2173" />
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="End Date" UniqueName="enddate">
                                <ItemTemplate>
                                    <asp:Label ID="date" runat="server" Text='<%# Eval("enddate") %>' />
                                    &nbsp;
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadDatePicker ID="picker1" runat="server" DbSelectedDate='<%# Bind("enddate") %>' MaxDate="12/31/2173" />
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="RadWindow" ConfirmText="Are you sure you want to Delete?" ConfirmTitle="Delete" HeaderStyle-Width="50px" HeaderText="Delete" Text="Delete" UniqueName="DeleteColumn" />
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>

                <p>&nbsp;</p>
                <telerik:RadListBox ID="SavedChangesList1" runat="server" Height="200px" Visible="false" Width="600px">
                </telerik:RadListBox>
           
                <telerik:RadListBox ID="SavedChangesList" runat="server" Height="200px" Visible="false" Width="600px" />
                <asp:SqlDataSource ID="PropertyHistories" runat="server" ConnectionString="<%$ ConnectionStrings:Bob %>" SelectCommand="spUAPPropertyHistory" SelectCommandType="StoredProcedure" DeleteCommand="spUAPPropertyHistoryDelete" DeleteCommandType="StoredProcedure" InsertCommand="spUAPPropertyHistoryInsert" InsertCommandType="StoredProcedure" UpdateCommand="spUAPPropertyHistoryUpdate" UpdateCommandType="StoredProcedure" OnDeleting="PropertyHistories_Deleting" OnInserting="PropertyHistories_Inserting" OnUpdating="PropertyHistories_Updating">
                  
                    <DeleteParameters>
                        <asp:Parameter Name="RMCCHistoryID" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="RMCCModelLvl2ID" Type="Int32" />
                        <asp:Parameter Name="RATPropID" Type="Int32" />
                        <asp:Parameter Name="StartDate" Type="String" />
                        <asp:Parameter Name="EndDate" Type="String" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="HotelList" DefaultValue="ABC" Name="Inncode" PropertyName="SelectedValue" Type="String" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="RMCCHistoryID" Type="Int32" />
                        <asp:Parameter Name="RMCCModelLvl2ID" Type="Int32" />
                        <asp:Parameter Name="StartDate" Type="String" />
                        <asp:Parameter Name="EndDate" Type="String" />
                    </UpdateParameters>
                  
                </asp:SqlDataSource>
                
                <asp:SqlDataSource ID="Hotels" runat="server" ConnectionString="<%$ ConnectionStrings:Bob %>" SelectCommand="Select Usename + ' - ' + Inncode as myview, Inncode 
                        From x 
                        Order by 1 Asc">
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="Contacts" runat="server" ConnectionString="<%$ ConnectionStrings:Bob %>" SelectCommand="Select Distinct CorpContactFullName 
                        From y
                        Order By 1">
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="Models" runat="server" ConnectionString="<%$ ConnectionStrings:Bob %>" SelectCommand="Select Distinct CorpContactFullName 
                        From z
                        Order By 1">
                </asp:SqlDataSource>
                        
        </telerik:RadAjaxPanel>
    </form>
</body>


BatchTest.cs:

 protected void PropertyHistory_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
    {
        SavedChangesList.Visible = true;
    }

    protected void PropertyHistory_ItemUpdated(object source, GridUpdatedEventArgs e)
    {
        GridEditableItem item = (GridEditableItem)e.Item;
        string id = item.GetDataKeyValue("RMCCHistoryID").ToString();

        if (e.Exception != null)
        {
            e.KeepInEditMode = true;
            e.ExceptionHandled = true;
            NotifyUser("ID " + id + " cannot be updated. Reason: " + e.Exception.Message);
        }
        else
            NotifyUser("ID " + id + " is updated!");        
    }

    protected void PropertyHistory_ItemInserted(object source, GridInsertedEventArgs e)
    {
        if (e.Exception != null)
        {
            e.ExceptionHandled = true;
            NotifyUser("Cannot be inserted. Reason: " + e.Exception.Message);
        }
        else
            NotifyUser("New product is inserted!");        
    }

    protected void PropertyHistory_ItemDeleted(object source, GridDeletedEventArgs e)
    {
        GridDataItem dataItem = (GridDataItem)e.Item;
        string id = dataItem.GetDataKeyValue("RMCCHistoryID").ToString();
        if (e.Exception != null)
        {
            e.ExceptionHandled = true;
            NotifyUser("ID " + id + " cannot be deleted. Reason: " + e.Exception.Message);
        }
        else
            NotifyUser("ID " + id + " is deleted!");
    }

    protected void PropertyHistory_PreRender(object sender, EventArgs e)
    {      
        //RadNumericTextBox w = (PersonnelHistory.MasterTableView.GetBatchColumnEditor("UnitsInStock") as GridNumericColumnEditor).NumericTextBox;
        //w.Width = Unit.Pixel(60);
        //TextBox x = (PersonnelHistory.MasterTableView.GetBatchColumnEditor("QuantityPerUnit") as GridTextBoxColumnEditor).TextBoxControl;
        //x.Width = Unit.Pixel(120);
    }
]
    private void NotifyUser(string message)
    {
        RadListBoxItem commandListItem = new RadListBoxItem();
        commandListItem.Text = message;
        SavedChangesList.Items.Add(commandListItem);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void PropertyHistories_Deleting(object sender, SqlDataSourceCommandEventArgs e)
    {
        // NOT BEING HIT!
        var x = e;
    }
    protected void PropertyHistories_Inserting(object sender, SqlDataSourceCommandEventArgs e)
    {
         // NOT BEING HIT!
        var x = e;
    }
    protected void PropertyHistories_Updating(object sender, SqlDataSourceCommandEventArgs e)
    {
         // NOT BEING HIT!
        var x = e;
    }








Konstantin Dikov
Telerik team
 answered on 13 Jun 2014
1 answer
52 views
Hello,

I am trying to get the item count in each group and display the count in the group footer and the total grid items count in the grid footer.

I tried several ways using the aggregate function which works fine at the grid footer level but at the group level it only displays the number of items in the page. Any help will be appreciated.

Thanks in Advance

Chaitanya Vemulapalli
Radoslav
Telerik team
 answered on 13 Jun 2014
6 answers
596 views
Hello everybody,

I already searched for the solution of my problem but did not find anything to work. I Build a RadGrid an bind it to a SQL Datasource. Now I want to fill the Dropdownlists in the Radgrid with values from a different code behind stored procedure. Somehow I can not access the two DropDownLists from my code behind. I would be very thankful if someone could help me out. Here is my code:

<telerik:RadGrid runat="server" ID="gridFktWipoHague" Culture="de-DE">
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn DataField="LAND_KZ" ReadOnly="true">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn DataField="PMMA_Add">
                <EditItemTemplate>
                    <telerik:RadDropDownList runat="server" ID="PMMA_Add_DropDown">
                    </telerik:RadDropDownList>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridDateTimeColumn DataField="HAGUE_DATUM">
            </telerik:GridDateTimeColumn>
            <telerik:GridTemplateColumn>
                <EditItemTemplate>
                    <telerik:RadDropDownList runat="server" ID="HAGUE_Add_DropDown">
                    </telerik:RadDropDownList>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="HAGUE_DELETE">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn ReadOnly="true" DataField="Counter_pm">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn ReadOnly="true" DataField="Counter_ps">
            </telerik:GridBoundColumn>
            <telerik:GridCheckBoxColumn DataField="TMVIEW">
            </telerik:GridCheckBoxColumn>
        </Columns>
    </MasterTableView>
    <ExportSettings>
        <Pdf PageWidth="">
        </Pdf>
    </ExportSettings>
 
</telerik:RadGrid>

Thank you very much,

Max
Max
Top achievements
Rank 1
 answered on 13 Jun 2014
2 answers
128 views
Is is possible to add plotbands to a date axis on a htmlchart? If so how? I can't find any reference to it.
Danail Vasilev
Telerik team
 answered on 13 Jun 2014
1 answer
160 views
Could you tell me why my code for RadGrid does not expand. It is very small but it has data in it. The only way I can expand it is to use with a meta tag and emulate IE7, but it is not what I want. 


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Grid.aspx.vb" Inherits="Grid.Grid" %>

<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
                </asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
                </asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
                </asp:ScriptReference>
            </Scripts>
        </telerik:RadScriptManager>
    <div>
    
    </div>
        <telerik:RadGrid runat="server" AutoGenerateColumns="False"
                    GridLines="None" Skin="Outlook" Height="95%" Width="98%" DataSourceID="SqlDataSource1">
                    <ClientSettings>
                        <Scrolling AllowScroll="False" UseStaticHeaders="True" ScrollHeight="200px" />
                    </ClientSettings>
                    <MasterTableView  TableLayout="Auto" Width="94%" DataSourceID="SqlDataSource1">
                        <RowIndicatorColumn Visible="False">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn Visible="False" Resizable="False">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </ExpandCollapseColumn>
                        <Columns>
                            <telerik:GridBoundColumn DataField="id" HeaderText="id" UniqueName="id" DataType="System.Int32" FilterControlAltText="Filter id column" SortExpression="id" >
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>

                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="masterBatchNo" FilterControlAltText="Filter masterBatchNo column" HeaderText="masterBatchNo" SortExpression="masterBatchNo" UniqueName="masterBatchNo">
                                <ColumnValidationSettings>
                                    <ModelErrorMessage Text="" />
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="processStage" FilterControlAltText="Filter processStage column" HeaderText="processStage" SortExpression="processStage" UniqueName="processStage">
                                <ColumnValidationSettings>
                                    <ModelErrorMessage Text="" />
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>
                        </Columns>
                        <EditFormSettings>
                            <PopUpSettings ScrollBars="None"></PopUpSettings>
                            <EditColumn UniqueName="EditCommandColumn1">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                   
                </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:projectCopyConnectionString %>" SelectCommand="SELECT [id], [masterBatchNo], [processStage] FROM [PV_Batch]"></asp:SqlDataSource>
    </form>
</body>
</html>
Princy
Top achievements
Rank 2
 answered on 13 Jun 2014
2 answers
118 views
Dear Telerik,

Is it possible to have multiple x-axis label as described in attachment?

Much appreciate for any help.

Thanks!
Danail Vasilev
Telerik team
 answered on 13 Jun 2014
1 answer
179 views
We are getting this error and using Telerik dlls from GAC.  If I go to design mode in .aspx webform and I see the controls but on the page it throws this error.

Error:
http://screencast.com/t/ldNrMHAg

Web.config:
http://screencast.com/t/vIB40g9zxn

http://screencast.com/t/vIB40g9zxn

http://screencast.com/t/t6vqlpTWQv


Danail Vasilev
Telerik team
 answered on 13 Jun 2014
7 answers
165 views
Hi,

When reordering items, the text is not html-encoded correctly!

Sample:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="listbox.aspx.vb" Inherits="TestaTredjepartWeb.listbox" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title>Test</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="s" runat="server">
        </asp:ScriptManager>
        <div>
            <telerik:RadListBox ID="rlb" runat="server" Width="330px" AllowReorder="true" EnableDragAndDrop="true">
                <Items>
                    <telerik:RadListBoxItem Text="<aaa>" />
                    <telerik:RadListBoxItem Text="<bbb>" />
                    <telerik:RadListBoxItem Text="<ccc>" />
                    <telerik:RadListBoxItem Text="<ddd>" />
                    <telerik:RadListBoxItem Text="<eee>" />
                    <telerik:RadListBoxItem Text="<fff>" />
                    <telerik:RadListBoxItem Text="<ggg>" />
                    <telerik:RadListBoxItem Text="<hhh>" />
                </Items>
            </telerik:RadListBox>
        </div>
    </form>
</body>
</html>

In the sample: try to reorder items, this makes the item text disappear!

Regards
Andreas
Boyan Dimitrov
Telerik team
 answered on 13 Jun 2014
4 answers
249 views
Hello
I am trying to autofill two of the many textboxes in my Radgrid. I want the first textbox to have the username of the logged on user and the other textbox should have current date and time.
With the help of another post I have managed this when creating a new record, but not when editing an existing record.
To be clear, if I edit an existing post I want the textboxes to have new values, current datetime and looged on user.
Here is my code:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
 
        If (e.CommandName = RadGrid.InitInsertCommandName) Then
            
            e.Canceled = True
            Dim loggedInUser = User.Identity.Name.ToString()
            Dim myDate As Date = Now()
            
            Dim defaultValue As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary()
            defaultValue("LastUpdated") = myDate.ToString()
            defaultValue("LastUpdatedBy") = loggedInUser.ToString()
            
            e.Item.OwnerTableView.InsertItem(defaultValue)
            End If
    End Sub


Thanks.
Anders
Top achievements
Rank 1
 answered on 13 Jun 2014
6 answers
2.3K+ views

ClientScript.RegisterStartupScript(

this.GetType(), "EnableCabType", "UncheckSelectAll('" + chkJobCategoryAll.ClientID + "','" + cblJobCategory.ClientID + "','" + cblCabinetType.ClientID + "','" + chkCabinetAll.ClientID + "');", true);

Seems the above script not at all fired in the ItemDataBound event of RadGrid's popup. Need this to be fired only from ItemDataBound

Any workarounds

Thanks

Regards
Raj

 

Princy
Top achievements
Rank 2
 answered on 13 Jun 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?