Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
1.0K+ views
When the Grid is loaded 

The below mentioned calls fails. I have deployed my site in IIS7 in classic mode.
GET http://localhost:12000/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_HiddenField&_TSM_CombinedScripts_=%3b%3bTelerik.Web.UI%2c+Version%3d2008.1.415.20%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3a7430ed72-7698-4d11-b25c-4354604bd0be%3a393f5085%3a34f9d57d%3ac6335cbd%3aa8595f70%3a4b6f7e66%3a80ec1d93%3aa9723048%3a9703c1f0%3aa3f85c94%3a819163f9%3abdca08ad%3a6f2bcae9%3a414de951 500 (Internal Server Error)
Also,

My config file looks as shown below:-

<add path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms" validate="true"/>
<add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false"/>



Thomas
Top achievements
Rank 1
 answered on 11 Nov 2014
1 answer
98 views
I always want to determine the name to save under so do not need the Save dialog to popup, how do I make it so that my save function gets called when the user clicks the save icon?

TIA
Mark H
Top achievements
Rank 1
 answered on 11 Nov 2014
5 answers
226 views
I have a splitter with some form controls inside it and when the area is resized with the split bar the controls dont stack, yet if I resize the whole browser window it does.  Do I need to call some sort of client resize function?
Vessy
Telerik team
 answered on 11 Nov 2014
1 answer
105 views
I was trying to follow the same code here on a telerik web site, becuase I need to do the smae thing, however it keeps telling me that I cannot get ahold of the raddatePicker that I put on the editform template, I am guessing its cause i am binding to a datatable.  I need to be able to get a hold of the raddate and time pickers and store them in a session datatable until i insert them into  a database.


<telerik:RadGrid ID="myradGrid" runat="server" Skin="Web20" CssClass="CentGrid50" Visible="false">
                            <MasterTableView AutoGenerateColumns="true" ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top">
                                <EditFormSettings EditFormType="Template">
                                    <FormTemplate>
                                        <table>
                                            <tr>
                                                <td>
                                                     <telerik:RadDatePicker ID="dtbegin" runat="server" Width="100px"></telerik:RadDatePicker>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                      <telerik:RadTimePicker ID="dtTimeBegin" runat="server" Width="100px">
                                                            <TimeView runat="server" Interval="00:30:00"></TimeView>
                                                        </telerik:RadTimePicker>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                      <telerik:RadTimePicker ID="RadTimePicker1" runat="server" Width="100px">
                                                            <TimeView runat="server" Interval="00:30:00"></TimeView>
                                                        </telerik:RadTimePicker>
                                                </td>
                                            </tr>
                                            <tr>
                                                  <td>
                                                    <asp:LinkButton ID="lnkSubmit" runat="server" text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'
                                                    CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>'></asp:LinkButton>
                                                         
                                                    <asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="false" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </FormTemplate>
                                </EditFormSettings>
                            </MasterTableView>
                        </telerik:RadGrid>
 
 
 
 Protected Sub myradGrid_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles myradGrid.NeedDataSource
        Dim dt As New DataTable
        dt.Columns.Add("Date Begin")
        dt.Columns.Add("Time Begin")
        dt.Columns.Add("Time End")
 
        If Session("Table") IsNot Nothing Then
            dt = DirectCast(Session("Table"), DataTable)
        End If
 
        myradGrid.DataSource = dt
        'populate RadGrid with datatable
        Session("Table") = dt
    End Sub
 
 
Heres my code to try to get at the insert into the datatable but it will not allow me to get at the raddate or time pickers, says cannot be converted from table cell.
 
  Protected Sub myradGrid_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles myradGrid.ItemCommand
        If (e.CommandName = RadGrid.PerformInsertCommandName) Then
            Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
            Dim dtbegin As RadDatePicker = DirectCast(editedItem("dtbegin"), RadDatePicker)
 
            Dim dt As DataTable
 
            dt = DirectCast(Session("Table"), DataTable)
            Dim drValues As DataRow = dt.NewRow()
            drValues("Date Begin") = dtbegin.Text
            drValues("Time Begin") = timeBegin.Text
            drValues("Time End") = timeEnd.Text
 
            dt.Rows.Add(drValues)
            'adding new row into datatable
            dt.AcceptChanges()
 
            Session("Table") = dt
 
            myradGrid.Rebind()
        End If
    End Sub
Eyup
Telerik team
 answered on 11 Nov 2014
1 answer
104 views
Hi 

our business requirement is to have a grid which when we choose to add a new record the first column will have a dropdown list with a collection of providers listed.  On selecting the required provider we want to update a number of the other columsn in the new record being added leaving 2 other fields to be entered before saving.

I have the dropdown working in the list but cannot work out how to update the other columns withinn the edit row

is this possible?

Konstantin Dikov
Telerik team
 answered on 11 Nov 2014
1 answer
62 views
I have a client that wants the bars in a RadHtmlChart column chart to have shaped top rather than the default squared end (see attached).

Is this possible? If so, how would I do it?
Danail Vasilev
Telerik team
 answered on 11 Nov 2014
1 answer
90 views
Hi, 
I have a radwindow, whose width and height are fixed. 
When i click on maximize button, my window is maximizing which is working perfectly file. but when i click on paging or filtering. my window is coming back to my fixed size.
I want my window to be remain maximized till user don't click on maximize button.

is their is any option to meet this requirement . Thanks.  
Marin Bratanov
Telerik team
 answered on 11 Nov 2014
1 answer
271 views
Hi,

I was hoping someone could help.  I have a radgrid that is populated by a list in code behind and have a checkbox in a Gridtemplate column. There is a button outside the grid that should collect all items that have checkbox checked and add results to a new db table.

This seem to work fine when grid is loaded and not filtered, however when the grid is filtered I get he following error:

Server Error in '/' Application.Collection was modified; enumeration operation may not execute.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

Source Error: 

Line 444: dbContext.SaveChanges();
Line 445:
Line 446: foreach (GridDataItem item in rgTracker.MasterTableView.Items)
Line 447: {
Line 448: CheckBox chkInvoiced = (CheckBox)item.FindControl("chkInvoiced");
Source File: e:\DropBox\Optimum Job tracker\Optimum\Pages\PensionLiteReport.aspx.cs    Line: 446 

Stack Trace: 

[InvalidOperationException: Collection was modified; enumeration operation may not execute.]
System.Collections.ArrayListEnumeratorSimple.MoveNext() +11165697
Optimum.Pages.PensionLiteReport.btnAddInvoice_Click(Object sender, EventArgs e) in e:\DropBox\Optimum Job tracker\Optimum\Pages\PensionLiteReport.aspx.cs:446
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9664630
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34212

Here is the button and radgrid:

<asp:LinkButton ID="btnAddInvoice" runat="server" CssClass="button small radius" Text="Add Checked to New Invoice" OnClick="btnAddInvoice_Click"></asp:LinkButton>
            <asp:Literal runat="server" ID="litAddInvoice"></asp:Literal>
            <div class="reset">
                 
                <telerik:RadGrid ID="rgTracker" runat="server"
                    AllowSorting="true" AllowPaging="true" PageSize="100" OnItemCreated="rgTracker_ItemCreated"
                    OnNeedDataSource="rgTracker_NeedDataSource"
                    AllowFilteringByColumn="True"
                    OnItemCommand="rgTracker_ItemCommand"
                    OnItemDataBound="rgTracker_ItemDataBound"
                    Skin="Windows7"
                     
                    OnPreRender="rgTracker_PreRender">
                    <ExportSettings HideStructureColumns="true">
                    </ExportSettings>
                    <GroupingSettings CaseSensitive="false" />
                    <MasterTableView AutoGenerateColumns="false" EnableHierarchyExpandAll="true" DataKeyNames="rdID, jobID" >
                         
                        <PagerStyle PageSizes="10,50,100,200,500" Mode="NextPrevAndNumeric" PageSizeLabelText="Show results: " Position="TopAndBottom" AlwaysVisible="true" />
                         
                        <Columns>
                            <telerik:GridBoundColumn DataField="rdID" Visible="false" ReadOnly="true" UniqueName="rdID" ForceExtractValue="Always" ConvertEmptyStringToNull="true"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="jobID" Visible="false" ReadOnly="true" UniqueName="jobID" ForceExtractValue="Always" ConvertEmptyStringToNull="true"></telerik:GridBoundColumn>
                            <telerik:GridHyperLinkColumn HeaderText="Customer Name" DataTextField="customerName" UniqueName="customerName" DataNavigateUrlFields="jobID" DataNavigateUrlFormatString="/pensionlitedetail/{0}" >
                                <HeaderStyle Width="150px" />
                            </telerik:GridHyperLinkColumn>
                            <telerik:GridBoundColumn HeaderText="Postcode" DataField="customerPostcode" UniqueName="customerPostcode" FilterControlWidth="30px" ReadOnly="true">
                                <HeaderStyle Width="50px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Phone" DataField="customerPhone" UniqueName="customerPhone" FilterControlWidth="70px" ReadOnly="true">
                                <HeaderStyle Width="90px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Pension Value" DataField="customerPensionValue" UniqueName="customerPensionValue" DataFormatString="{0:C}" FilterControlWidth="40px" ReadOnly="true">
                                <HeaderStyle Width="75px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridDateTimeColumn HeaderText="Sale Date" DataField="saleDate" UniqueName="saleDate" DataFormatString="{0:g}" PickerType="DatePicker" EnableRangeFiltering="true" FilterControlWidth="100px" EnableTimeIndependentFiltering="true" ReadOnly="true">
                                <HeaderStyle Width="120px" />
                            </telerik:GridDateTimeColumn>
                            <telerik:GridDateTimeColumn HeaderText="Appt Date" DataField="apptDate" UniqueName="apptDate" DataFormatString="{0:g}" PickerType="DatePicker" EnableRangeFiltering="true" FilterControlWidth="100px" EnableTimeIndependentFiltering="true" ReadOnly="true">
                                <HeaderStyle Width="120px" /></telerik:GridDateTimeColumn>
                            <telerik:GridDateTimeColumn HeaderText="Updated" DataField="updatedDate" UniqueName="updatedDate" DataFormatString="{0:g}" PickerType="DatePicker" EnableRangeFiltering="true" FilterControlWidth="100px" EnableTimeIndependentFiltering="true" ReadOnly="true">
                                <HeaderStyle Width="120px" /></telerik:GridDateTimeColumn>
                            <telerik:GridBoundColumn HeaderText="Current Status" DataField="currentStatus" UniqueName="currentStatus" ReadOnly="true">
                                <HeaderStyle Width="100px" />
                                <FilterTemplate>
                                    <telerik:RadComboBox ID="RadComboBoxStatus" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("currentStatus").CurrentFilterValue %>'
                                        runat="server" OnClientSelectedIndexChanged="StatusIndexChanged" Skin="Windows7" Width="200px">
                                        <Items>
                                            <telerik:RadComboBoxItem Text="All" />
                                            <telerik:RadComboBoxItem Text="Lead Pending" Value="Lead Pending" />
                                            <telerik:RadComboBoxItem Text="Lead Accepted" Value="Lead Accepted" />
                                            <telerik:RadComboBoxItem Text="Lead Rejected" Value="Lead Rejected" />
                                        </Items>
                                    </telerik:RadComboBox>
                                    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                                        <script type="text/javascript">
                                            function StatusIndexChanged(sender, args) {
                                                var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                tableView.filter("currentStatus", args.get_item().get_value(), "EqualTo");
                                            }
                                         
                                        </script>
                                    </telerik:RadScriptBlock>
                                </FilterTemplate>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Invoiced" DataField="invoiced" UniqueName="invoiced" Display="false" ForceExtractValue="Always" ReadOnly="true">
                                <HeaderStyle Width="50px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn UniqueName="InvoicedCheckboxColumn" AllowFiltering="false">
                                <HeaderStyle Width="20px" />
                                 
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkInvoiced" runat="server" />
                                </ItemTemplate>
                                <HeaderTemplate>
                                    Invoiced<br /><asp:CheckBox ID="chkInoicedHeader" runat="server" OnCheckedChanged="chkInoicedHeader_CheckedChanged" AutoPostBack="true" />
                                </HeaderTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn HeaderText="Credit" DataField="credited" UniqueName="credited" Display="false" ForceExtractValue="Always" ReadOnly="true">
                                <HeaderStyle Width="50px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn UniqueName="CreditedCheckboxColumn" AllowFiltering="false">
                                <HeaderStyle Width="20px" />
                                 
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkCredited" runat="server" />
                                </ItemTemplate>
                                <HeaderTemplate>
                                    Credited<br /><asp:CheckBox ID="chkCreditedHeader" runat="server" OnCheckedChanged="chkCreditedHeader_CheckedChanged" AutoPostBack="true" />
                                </HeaderTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                         
                    </MasterTableView>
                </telerik:RadGrid>
            </div>

and here is the related codebehind:

protected void rgTracker_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
             
 
            rgTracker.DataSource = GetData();
        }
 
        protected void rgTracker_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
 
        }
 
        protected void rgTracker_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = (GridDataItem)e.Item;
                string cStatus = dataItem["currentStatus"].Text;
 
                if (cStatus == "Lead Rejected")
                {
                    dataItem.BackColor = Color.LightCoral;
                }
                if (cStatus == "Lead Accepted")
                {
                    dataItem.BackColor = Color.LightGreen;
                }
 
                CheckBox chkInvoiced = (CheckBox)e.Item.FindControl("chkInvoiced");
                string sInv = dataItem["invoiced"].Text;
                bool bInv = false;
                Boolean.TryParse(sInv, out bInv);
                if (bInv)
                {
                    chkInvoiced.Checked = true;
                    chkInvoiced.Enabled = false;
                }
 
                CheckBox chkCredited = (CheckBox)e.Item.FindControl("chkCredited");
                string sCred = dataItem["credited"].Text;
                bool bCred = false;
                Boolean.TryParse(sCred, out bCred);
                if (bCred)
                {
                    chkCredited.Checked = true;
                    chkCredited.Enabled = false;
                }
 
            }
        }
 
        protected void rgTracker_PreRender(object sender, EventArgs e)
        {
 
        }
 
        protected void rgTracker_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            GridFilteringItem filteringItem = e.Item as GridFilteringItem;
            if (filteringItem != null)
            {
                LiteralControl literalTo1 = filteringItem["saleDate"].Controls[3] as LiteralControl;
                literalTo1.Text = "<br />To:";
 
                LiteralControl literalTo2 = filteringItem["apptDate"].Controls[3] as LiteralControl;
                literalTo2.Text = "<br />To:";
 
                LiteralControl literalTo3 = filteringItem["updatedDate"].Controls[3] as LiteralControl;
                literalTo3.Text = "<br />To:";
            }
        }
 
        protected void chkInoicedHeader_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox headerCheckBox = (sender as CheckBox);
            foreach (GridDataItem dataItem in rgTracker.MasterTableView.Items)
            {
                if ((dataItem.FindControl("chkInvoiced") as CheckBox).Enabled)
                {
                    (dataItem.FindControl("chkInvoiced") as CheckBox).Checked = headerCheckBox.Checked;
                    dataItem.Selected = headerCheckBox.Checked;
                }
            }
        }
 
        protected void chkCreditedHeader_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox headerCheckBox = (sender as CheckBox);
            foreach (GridDataItem dataItem in rgTracker.MasterTableView.Items)
            {
                if ((dataItem.FindControl("chkCredited") as CheckBox).Enabled)
                {
                    (dataItem.FindControl("chkCredited") as CheckBox).Checked = headerCheckBox.Checked;
 
                    dataItem.Selected = headerCheckBox.Checked;
                }
            }
        }
 
        protected void btnAddInvoice_Click(object sender, EventArgs e)
        {
            //TODO: Wire in credits and check for duplicate sales
            Invoice inv = new Invoice();
 
            inv.ClientID = 11;
            inv.InvoiceDate = DateTime.Now;
 
            dbContext.Invoices.Add(inv);
            dbContext.SaveChanges();
             
            foreach (GridDataItem item in rgTracker.MasterTableView.Items)
            {
                CheckBox chkInvoiced = (CheckBox)item.FindControl("chkInvoiced");
                if (chkInvoiced.Checked && chkInvoiced.Enabled)
                {
                    //ReportDetails rd = (ReportDetails)item.DataItem;
 
                    //litAddInvoice.Text += string.Format("<div data-alert class='alert-box info radius'>{0} {1} - {2}</div>", rd.customerName, rd.customerPhone, rd.jobId);
 
                    string strJID = item.GetDataKeyValue("jobID").ToString();
                    litAddInvoice.Text += string.Format("<div data-alert class='alert-box info radius'>Job ID: {0}</div>", strJID);
 
                    int intJID = 0;
                    Int32.TryParse(strJID, out intJID);
 
                    Job j = new Job();
                    j = dbContext.Jobs.Where(x => x.ID == intJID).FirstOrDefault();
 
                    if (j.ID > 0)
                    {
                        InvoiceDetail id = new InvoiceDetail();
                        id.JobID = j.ID;
                        id.Credit = false;
                        id.JobSchemaID = j.JobSchemata.OrderByDescending(x => x.ID).Select(x => x.ID).FirstOrDefault();
                        id.StatusWhenInvoiced = j.JobSchemata.OrderByDescending(x => x.ID).Select(x => x.JobStage1.JobStage1).FirstOrDefault();
                        id.InvoiceID = inv.ID;
 
                        dbContext.InvoiceDetails.Add(id);
                        dbContext.SaveChanges();
                    }
                }
                CheckBox chkCredited = (CheckBox)item.FindControl("chkCredited");
                if (chkCredited.Checked && chkCredited.Enabled)
                {
                    //ReportDetails rd = (ReportDetails)item.DataItem;
 
                    //litAddInvoice.Text += string.Format("<div data-alert class='alert-box info radius'>{0} {1} - {2}</div>", rd.customerName, rd.customerPhone, rd.jobId);
 
                    string strJID = item.GetDataKeyValue("jobID").ToString();
                    litAddInvoice.Text += string.Format("<div data-alert class='alert-box warning radius'>Job ID: {0}</div>", strJID);
 
                    int intJID = 0;
                    Int32.TryParse(strJID, out intJID);
 
                    Job j = new Job();
                    j = dbContext.Jobs.Where(x => x.ID == intJID).FirstOrDefault();
 
                    if (j.ID > 0)
                    {
                        InvoiceDetail id = new InvoiceDetail();
                        id.JobID = j.ID;
                        id.Credit = true;
                        id.JobSchemaID = j.JobSchemata.OrderByDescending(x => x.ID).Select(x => x.ID).FirstOrDefault();
                        id.StatusWhenInvoiced = j.JobSchemata.OrderByDescending(x => x.ID).Select(x => x.JobStage1.JobStage1).FirstOrDefault();
                        id.InvoiceID = inv.ID;
 
                        dbContext.InvoiceDetails.Add(id);
                        dbContext.SaveChanges();
                    }
                }
 
                rgTracker.Rebind();
            }
 
            litAddInvoice.Text += "<div data-alert class='alert-box success radius'>Invoice Generated</div>";
        }

Any help would be greatly appreciated

Cheers

Dale
Kostadin
Telerik team
 answered on 11 Nov 2014
2 answers
417 views
Hi Team,

I am using the telerik dll version of 2014.2.724.45

I am facing one issue while editing the grid.

Let me explain the issue.

I have a grid with 5 columns in it and has some data populated. I am implementing batch editing(with batch editing type=cell) for this grid.

When I click on the add new record I am  inserting a new row, here I don't have any issue.
While updating the record I want to make one column non editable, other columns are editable.
How can I achieve this.Please see the aspx and .cs files below

ASPX FILE:

<telerik:RadGrid ID="DischargeRadGrid"   OnItemDataBound="DsichargeRadGridFormat_OnItemDataBound" runat="server" AutoGenerateColumns="false"
                            CssClass="TransferGridPanel" Height="370px" Width="500px" OnItemCommand="DischargeRadGrid_ItemCommand"
                            OnBatchEditCommand="DischargeRadGrid_BatchEditCommand">
                           <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="Discharge_ID">
                            <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add NewDelivery" />
                               <BatchEditingSettings EditType="Cell" />
                                                                 <Columns>
                                    <telerik:GridBoundColumn  UniqueName="DeliveryNo" DataField="Discharge_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="ShipTo"
                                        DataField="Site_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="ShipToName"
                                        DataField="SiteAddress" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="DischargeStart"
                                        DataField="DischargeStartTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="DischargeEnd"
                                        DataField="DischargeEndTime">
                                    </telerik:GridBoundColumn>
                                   
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>                           
                           
                            <Scrolling AllowScroll="true"/>
                               
                            </ClientSettings>
                        </telerik:RadGrid>


ASPX.CS FILE


 protected void DischargeRadGrid_BatchEditCommand(object source, GridBatchEditingEventArgs e)
    {
        foreach (GridBatchEditingCommand command in e.Commands)
        {
           
            Hashtable newValues = command.NewValues;
            Hashtable oldValues = command.OldValues;
            string newDischargeId = newValues["Discharge_ID"].ToString();
           
            string newShipTo = newValues["Site_ID"].ToString();
           
            DateTime? dischargeStartTime = DateTime.Now;
            DateTime? dischargeEndTime = DateTime.Now;
            Int32 dropindex;
            Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
            dropindex = dischargeManager.GetDropIndexCountByDishargeId(shipmentID);
            List<DischargeEntity> dischargeDetails = new List<DischargeEntity>();
            dischargeDetails = dischargeManager.GetDischargeByShipmentId(shipmentID);
            if (command.Type == GridBatchEditingCommandType.Update)
            {
              
                RadWindowManager1.RadConfirm(HTMLEncoder.Encode(MyGlobal.SDP_ALERT_WHILE_UPDATE_LOAD), "confirmCallBackFn", 400, 100, null, null);
              
                var DischargeDal = new DischargeDal();               
                var discharge = new DischargeEntity
                {
                    Discharge_ID = Convert.ToInt64(newDischargeId),
                    Site_ID = Convert.ToInt64(newShipTo),
                    Job_ID = new Guid(),
                    Shipment_ID = shipmentID,
                    Planned = false,                   
                    DropIndex = dropindex,
                    Urgency = dischargeDetails[0].Urgency,
                    DischargeStartTime = dischargeStartTime,
                    DischargeEndTime = dischargeEndTime,                };
                discharge.Discharge_ID = DischargeDal.UpdateDischargeByDischargeId(discharge).Discharge_ID;
                dischargeDetailWsList = new List<DischargeDetailExtraEntity>();
                dischargeDetailWsList = dischargeDetailManager.GetDischargesByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
                DischargeRadGrid.DataSource = dischargeDetailWsList;
                DischargeRadGrid.DataBind();
            }
            if (command.Type == GridBatchEditingCommandType.Insert)
            {
               
               RadWindowManager1.RadConfirm(HTMLEncoder.Encode(MyGlobal.SDP_ALERT_WHILE_ADD_NEW_LOAD), "confirmCallBackFn", 400, 100, null, null);
               List<DischargeEntity> currentList = (List<DischargeEntity>)Session[_sesDischargeList];              
               DischargeEntity de = currentList[0];
                var DischargeDal = new DischargeDal();              
                if(!(Boolean)de.Planned)
                {
                   
                }
                var discharge = new DischargeEntity
                {
                    Job_ID = new Guid(),
                    Discharge_ID = Convert.ToInt64(newDischargeId),
                    Shipment_ID = shipmentID,
                    DropIndex = dropindex,
                    Site_ID = Convert.ToInt64(newShipTo),
                    Planned = false,
                    PONumber = dischargeDetails[0].PONumber,
                    Urgency = dischargeDetails[0].Urgency,
                    DischargeStartTime = dischargeStartTime,
                    DischargeEndTime=dischargeEndTime,
                };
                discharge.Discharge_ID = DischargeDal.CreateDischarge(discharge).Discharge_ID;
                dischargeDetailWsList = new List<DischargeDetailExtraEntity>();
                dischargeDetailWsList = dischargeDetailManager.GetDischargesByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
                DischargeRadGrid.DataSource = dischargeDetailWsList;
                DischargeRadGrid.DataBind();            
            }
            if (command.Type == GridBatchEditingCommandType.Delete)
            {
                //perform delete
            }
        }
    }


Please send me the answer asap.it is very urgent.
Thanks in advance.
Pavlina
Telerik team
 answered on 11 Nov 2014
1 answer
98 views
Scenario

I am creating a user control that contains a RadGrid. The user control will have properties that specify the order of the columns in the RadGrid. I plan on using code similar to the snippet taken from http://www.telerik.com/help/aspnet-ajax/grid-reordering-columns.html

GridColumnCollection cols = grid.MasterTableView.Columns;
GridColumn c = cols.FindByUniqueName(columnName);
if (c != null){
    int start = c.OrderIndex;
    for (int i= start; i < cols.Count; i++) 
    {
        c = cols[i];
        if (i < cols.Count - 1)  
            c.OrderIndex = i+1;
        else    
            c.OrderIndex = start; 
    }
}

Question
1. At what point in the pages life cycle should the code be executed? (i.e. page_load, page_init etc)
2. If I do not want to execute the code based on the page lifecycle, are there event(s) based on the RadGrid's life cycle that can be used to execute the code? (i.e. RadGrid1_Init, RadGrid1_Load, RadGrid1_PreRender, RadGrid1_ColumnCreated etc)
3. Any gotcha's I should be aware about?
Kostadin
Telerik team
 answered on 11 Nov 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?