Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
952 views
Hi,

How can I change DataBinder.Eval to Container.DataItem)["Value"] if grid is binding from data table.

<%#((System.Data.DataRowView)Container.DataItem)["Value"] %> is working fine in ItemTemplate but not in EditItemTemplate.


line of code which is not working.

 <EditItemTemplate>
<asp:TextBox ID="txtRestrictValue" runat="server" MaxLength="200" Text='<%#((System.Data.DataRowView)Container.DataItem)["Value"] %>'></asp:TextBox>
</EditItemTemplate>

it gives following error:
Unable to cast object of type 'Telerik.Web.UI.GridInsertionObject' to type 'System.Data.DataRowView'.

Warm Thnaks
Reyaz
Jayesh Goyani
Top achievements
Rank 2
 answered on 16 Nov 2011
2 answers
77 views
I have a grid with a formtemplate. The formtemplate has 4 buttons: Save (CommandName="Update"), Cancel (CommandName="Cancel"), GoToStart (OnClick="btnGoToStart_Click"), PrintToPdf (OnClick="btnPrintToPdf_Click"). As you can see 2 of the buttons perform a grid command, and 2 of the buttons has their own click events. After clicking the Save button or Cancel button, the grid does exactly what's expected. But, if I click on Save, and then click on GoToStart or PrintToPdf buttons, they do not enter theis events, but acts like the Cancel button. What am I missing here?
Jayesh Goyani
Top achievements
Rank 2
 answered on 16 Nov 2011
10 answers
227 views
Hi,

My field datatype is System.Decimal. When page culture is en-US, filtering is works but when page culture is tr-TR - decimalseperator is ',' (comma) - filtering is not working. I'm getting - ')' or operator expected - javascript error.

Why can this be, any suggestions?
Wiktor
Top achievements
Rank 1
 answered on 16 Nov 2011
6 answers
162 views
Hello,

I have a page where I am using tooltips to change items like this:

Contact E-mail: me@somewhere.com   change  <--clicking change brings up a tooltip with the textbox to change the e-mail address.

I have a conundrum.  Using the tooltip with RenderInPageRoot set to false, my tooltip will appear in the incorrect position, then "jump" up next to the element. This is due to the way my styles are defined, and unfortunately I cannot change them.  However, ajax postbacks work great in this scenario.

However, if I use RenderInPageRoot=true, the tooltip shows up perfectly next to the element, but then I get the behavior where Ajax will work on the first postback, not on the next, then again on the next.  So it alternates between partial and full postbacks.

Here is a snippet of the code:

<div class="block append-bottom-sm">
            <div class="span-6"
                <asp:Label ID="lblContactEmailTitle" runat="server" Text="Contact E-mail:" AssociatedControlID="lContactEmail" /> 
            </div>
            <div class="span-5"
                <asp:Label ID="lContactEmail" runat="server"></asp:Label> 
                <telerik:RadToolTip runat="server" ID="radttContactEmail" HideEvent="FromCode" Position="MiddleLeft" 
                    Width="250px" Height="70px" Animation="Slide" ShowEvent="OnClick"  ShowDelay="0"  RenderInPageRoot="true" 
                    RelativeTo="Element" TargetControlID="lbContactEmail"
 
                    <asp:Label ID="Label5" runat="server">Please enter your Contact Email:</asp:Label> 
                    <br /> 
                    <asp:TextBox ID="tbContactEmail" runat="server" ValidationGroup="ContactEmailValidationGroup"></asp:TextBox> 
                   <br /> 
                    <asp:RegularExpressionValidator  ID="revContactEmail" runat="server" ValidationGroup="ContactEmailValidationGroup" Display="Dynamic" 
                    ValidationExpression="^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$" 
                    ControlToValidate="tbContactEmail">The Contact Email must have a valid format.</asp:RegularExpressionValidator>                   
                     
                    <asp:LinkButton ID="lbContactEmailSave" runat="server" ValidationGroup="ContactEmailValidationGroup">Save</asp:LinkButton> 
                    <asp:LinkButton ID="lbContactEmailCancel" runat="server" ValidationGroup="" CausesValidation="false" OnClientClick="HideTooltip(); return false;">Cancel</asp:LinkButton> 
                </telerik:RadToolTip> 
            </div> 
            <div class="span-3"
                <asp:LinkButton ID="lbContactEmail" runat="server" OnClientClick="SetContactEmail();">Change</asp:LinkButton> 
            </div> 
        </div> 

Here is the AjaxManager setup (pnlContactInfo surrounds all the code that you see in the snippet above):
<telerik:RadAjaxLoadingPanel ID="radalp" runat="server" BackgroundPosition="Center" Skin="Default" /> 
        <telerik:RadAjaxManager ID="radam" runat="server" EnablePageHeadUpdate="false" DefaultLoadingPanelID="radalp" > 
            <AjaxSettings>                 
 
                <telerik:AjaxSetting AjaxControlID="lbContactEmailSave"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="pnlContactInfo" /> 
                         
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
 
            </AjaxSettings> 
        </telerik:RadAjaxManager>  


Here is the javascript function that is called when the user clicks the "Change" button:

 function SetContactEmail() { 
        document.getElementById('<%=tbContactEmail.ClientID%>').value = document.getElementById('<%=lContactEmail.ClientID%>').innerHTML
        Page_ClientValidate('ContactEmailValidationGroup'); // Erase any message which may have been displayed the last time after a Cancel was clicked. 
    } 


And here is the code-behind that is happening on save:

 Private Sub lbContactEmailSave_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles lbContactEmailSave.Click 
        Dim VZID As String = hidVZID.Value 
        Dim newEmail As String = tbContactEmail.Text 
        Dim SQL As String = 'some sql here... 
        Dim myData As New clsData() 
        myData.ExecuteSQL(SQL, CommandType.Text) 
        lContactEmail.Text = newEmail 
    End Sub 


Any help would be greatly appreciated.

Thanks,
Gene

Marin Bratanov
Telerik team
 answered on 16 Nov 2011
3 answers
47 views
I have a small bit of validation that when fails cancels an update. When this happens, the fields that i want to stay in edit mode do so but one column that is explicity set to readonly becomes editable also. Is there any reason for this?
Tsvetina
Telerik team
 answered on 16 Nov 2011
5 answers
208 views
Hello,

I have below RadScheduler control on my page. Code as below:

<asp:Content ID="Content1" ContentPlaceHolderID="main" runat="Server">
    <telerik:RadScheduler runat="server" ID="schedular" DataKeyField="ID" DataSubjectField="Subject"
        DataStartField="Start" DataEndField="End" StartEditingInAdvancedForm="true" DataRecurrenceField="RecurrenceRule"
        DataRecurrenceParentKeyField="RecurrenceParentID" OnAppointmentInsert="schedular_AppointmentInsert"
        OnAppointmentDelete="schedular_AppointmentDelete" StartInsertingInAdvancedForm="true">
    </telerik:RadScheduler>
</asp:Content>

I can insert the appointment easily but when I delete the appointment the Delete event (OnAppointmentDelete = "schedular_AppointmentDelete") gets Fired twice.

If I remove the recurrence properties (i.e.DataRecurrenceField, DataRecurrenceParentKeyField) then it works fine but I need Recurrence functionality.

Please let me know the solution to this problem.

Thanks,
Mayur.
Ivana
Telerik team
 answered on 16 Nov 2011
0 answers
472 views
Hi,
I have used a dynamically generated RadGrid for my application.
I would like to use the following functions:
1) Freeze header
2) Freeze columns
3) Resize one of the column
I know there's an article saying that resizing the column does not work with freezing header, so if we are to only use the freeze header and columns there are still some issues

here's the issues and settings I used:
- Freeze header only, no freezing columns
The grid has some alignment issue when scroll to the end, the header and content line is not aligned.
Pls see freezeheaderalignment.jpg
- Freeze header and column (must use layout = auto to make it show)
The last column disappear when using both freeze header and column and somehow the header height become very big and is it because of my fixed height, now i have 3 vertical scroll bars :(
Pls see freezeheaderncolumn.jpg

Also I noticed that I have to specify the width of each column otherwise the column will shrink, is there any auto-size property to automatically resize the column width as per content?

Here's my code:
RadGrid1 = new RadGrid();
RadGrid1.ID = "RadGrid1";
RadGrid1.Height = Unit.Pixel(535);
 
int intDefaultPercentage = 99;
bool isFixed = false;
if (!ConfigHelper.OPDashboardLayout.Equals(""))
{
    if (ConfigHelper.OPDashboardLayout.ToUpper().Equals("Fixed"))
        isFixed = true;
    RadGrid1.MasterTableView.TableLayout = (GridTableLayout)Enum.Parse(typeof(GridTableLayout), ConfigHelper.OPDashboardLayout);
}
 
RadGrid1.AutoGenerateColumns = false;
RadGrid1.ClientSettings.Scrolling.AllowScroll = true;
RadGrid1.ItemDataBound += new GridItemEventHandler(RadGrid1_ItemDataBound);
RadGrid1.PreRender += new EventHandler(RadGrid1_PreRender);
RadGrid1.ColumnCreated += new GridColumnCreatedEventHandler(RadGrid1_ColumnCreated);
RadGrid1.DetailTableDataBind += new GridDetailTableDataBindEventHandler(RadGrid1_DetailTableDataBind);
RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
RadGrid1.ExcelExportCellFormatting += new OnExcelExportCellFormattingEventHandler(RadGrid1_ExcelExportCellFormatting);
 
RadGrid1.MasterTableView.Name = "Master";
RadGrid1.MasterTableView.DataKeyNames = new string[] {"KIID"};
RadGrid1.MasterTableView.GroupLoadMode = GridGroupLoadMode.Client;
 
RadGrid1.MasterTableView.Width = Unit.Percentage(intDefaultPercentage);
RadGrid1.MasterTableView.HeaderStyle.Wrap = true;
if (isFixed)
{
    RadGrid1.CssClass = "AutoShrink";
    RadGrid1.MasterTableView.CssClass = "AutoShrink";
}
//RadGrid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
 
GridRelationFields relationFields = new GridRelationFields();
relationFields.MasterKeyField = "KIID";
relationFields.DetailKeyField = "KIID";
RadGrid1.MasterTableView.ParentTableRelation.Add(relationFields);
 
RadGrid1.ClientSettings.AllowGroupExpandCollapse = true;
GridGroupByExpression groupExpression = new GridGroupByExpression();
GridGroupByField selectField = new GridGroupByField();
//selectField.FieldAlias = "Vertical";
selectField.HeaderText = " ";
selectField.FieldName = "VerticalDisplayName";
selectField.HeaderValueSeparator = "";
GridGroupByField groupField = new GridGroupByField();
groupField.FieldName = "VerticalDisplaySequence";
groupExpression.SelectFields.Add(selectField);
groupExpression.GroupByFields.Add(groupField);
RadGrid1.MasterTableView.GroupByExpressions.Add(groupExpression);
 
#region MasterView
GridBoundColumn processColumn = new GridBoundColumn();
processColumn.UniqueName = "ProcessDescription";
processColumn.DataField = "ProcessDescription";
processColumn.HeaderText = "Process Description" + ApplicationConstant.LINEBREAK + "Key Indicator Code";
 
if (ConfigHelper.OPDashboardWidthProcess > 0)
    processColumn.HeaderStyle.Width = Unit.Pixel(ConfigHelper.OPDashboardWidthProcess);
 
if (ConfigHelper.OPDashboardResizeRemarks)
    processColumn.Resizable = false;
RadGrid1.MasterTableView.Columns.Add(processColumn);
 
GridBoundColumn KIColumn = new GridBoundColumn();
KIColumn.UniqueName = "KI";
KIColumn.DataField = "KIDescription";
KIColumn.HeaderText = "Key Indicator Description";
if (ConfigHelper.OPDashboardWidthKI > 0)
    KIColumn.HeaderStyle.Width = Unit.Pixel(ConfigHelper.OPDashboardWidthKI);
if (ConfigHelper.OPDashboardResizeRemarks)
    KIColumn.Resizable = false;
RadGrid1.MasterTableView.Columns.Add(KIColumn);
 
GridBoundColumn KIColumnHidden = new GridBoundColumn();
KIColumnHidden.UniqueName = "KIOriginal";
KIColumnHidden.DataField = "KIDescription";
if (ConfigHelper.OPDashboardWidthKI > 0)
    KIColumn.HeaderStyle.Width = Unit.Pixel(ConfigHelper.OPDashboardWidthKI);
KIColumnHidden.Visible = false;
RadGrid1.MasterTableView.Columns.Add(KIColumnHidden);
 
GridBoundColumn remarksColumn = new GridBoundColumn();
remarksColumn.UniqueName = "Remarks";
remarksColumn.DataField = "Remarks";
remarksColumn.HeaderText = "Remarks";
if (ConfigHelper.OPDashboardWidthRemarks > 0)
    remarksColumn.HeaderStyle.Width = Unit.Pixel(ConfigHelper.OPDashboardWidthRemarks);
RadGrid1.MasterTableView.Columns.Add(remarksColumn);
 
GridBoundColumn remarksColumnHidden = new GridBoundColumn();
remarksColumnHidden.UniqueName = "RemarksOriginal";
remarksColumnHidden.DataField = "Remarks";
remarksColumnHidden.Visible = false;
if (ConfigHelper.OPDashboardWidthRemarks > 0)
    remarksColumn.HeaderStyle.Width = Unit.Pixel(ConfigHelper.OPDashboardWidthRemarks);
RadGrid1.MasterTableView.Columns.Add(remarksColumnHidden);
 
for (int i = 1; i <= int.Parse(ConfigHelper.OPDashboardMaxPeriodRange); i++)
{
    GridTemplateColumn masterPeriodColumn = new GridTemplateColumn();
    masterPeriodColumn.UniqueName = PERIODCOLUMNPREFIX + i.ToString();
    masterPeriodColumn.ItemTemplate = new KRIPeriodTemplateColumn(i.ToString());
    masterPeriodColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
    if (ConfigHelper.OPDashboardWidthMonths > 0)
        masterPeriodColumn.HeaderStyle.Width = Unit.Pixel(ConfigHelper.OPDashboardWidthMonths);
    masterPeriodColumn.HeaderStyle.Wrap = true;
    if (ConfigHelper.OPDashboardResizeRemarks)
        masterPeriodColumn.Resizable = false;
    RadGrid1.MasterTableView.Columns.Add(masterPeriodColumn);
}
 
GridTemplateColumn thresholdColumn = new GridTemplateColumn();
thresholdColumn.UniqueName = "ThresholdColumn";
thresholdColumn.ItemTemplate = new KRIThresholdTemplateColumn();
thresholdColumn.Visible = blnShowThreshold;
if (ConfigHelper.OPDashboardWidthThreshold > 0)
    thresholdColumn.HeaderStyle.Width = Unit.Pixel(ConfigHelper.OPDashboardWidthThreshold);
//thresholdColumn.HeaderText = "Threshold";
thresholdColumn.HeaderText = "Threshold" + ApplicationConstant.LINEBREAK + "(in $)";
thresholdColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
thresholdColumn.HeaderStyle.Wrap = true;
if (ConfigHelper.OPDashboardResizeRemarks)
    thresholdColumn.Resizable = false;
RadGrid1.MasterTableView.Columns.Add(thresholdColumn);
 
#endregion
 
#region DetailView
GridTableView tableView1 = new GridTableView();
tableView1.Name = "Detail";
tableView1.DataKeyNames = new string[] { "KIID","AssetTypeCode" };
tableView1.Width = Unit.Percentage(intDefaultPercentage);
tableView1.HeaderStyle.Wrap = true;
RadGrid1.MasterTableView.DetailTables.Add(tableView1);
 
GridBoundColumn assetDescriptionColumn = new GridBoundColumn();
assetDescriptionColumn.UniqueName = "AssetTypeDescription";
assetDescriptionColumn.DataField = "AssetTypeDescription";
assetDescriptionColumn.HeaderText = "Description";
if (ConfigHelper.OPDashboardWidthProcess > 0 || ConfigHelper.OPDashboardWidthKI > 0)
    assetDescriptionColumn.HeaderStyle.Width = Unit.Pixel(ConfigHelper.OPDashboardWidthProcess + ConfigHelper.OPDashboardWidthKI);
tableView1.Columns.Add(assetDescriptionColumn);
 
GridBoundColumn assetTypeColumn = new GridBoundColumn();
assetTypeColumn.UniqueName = "AssetTypeCode";
assetTypeColumn.DataField = "AssetTypeCode";
assetTypeColumn.HeaderText = "Asset Type";
if (ConfigHelper.OPDashboardWidthRemarks > 0)
    assetTypeColumn.HeaderStyle.Width = Unit.Pixel(ConfigHelper.OPDashboardWidthRemarks);
tableView1.Columns.Add(assetTypeColumn);
 
//Pad column to align with Remarks
GridHyperLinkColumn paddingRemarksColumn = new GridHyperLinkColumn();
paddingRemarksColumn.UniqueName = "PaddingRemarksColumn";
paddingRemarksColumn.Text = "";
paddingRemarksColumn.HeaderText = "";
tableView1.Columns.Add(paddingRemarksColumn);
 
for (int i = 1; i <= int.Parse(ConfigHelper.OPDashboardMaxPeriodRange); i++)
{
    GridTemplateColumn detailPeriodColumn = new GridTemplateColumn();
    detailPeriodColumn.UniqueName = PERIODCOLUMNPREFIX + i.ToString();
    detailPeriodColumn.ItemTemplate = new KRIPeriodTemplateColumn(i.ToString());
    detailPeriodColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
    if (ConfigHelper.OPDashboardWidthMonths > 0)
        detailPeriodColumn.HeaderStyle.Width = Unit.Pixel(ConfigHelper.OPDashboardWidthMonths);
    tableView1.Columns.Add(detailPeriodColumn);
}
#endregion
 
#region Freeze Header
RadGrid1.ClientSettings.Scrolling.UseStaticHeaders = ConfigHelper.OPDashboardFreezeHeader;
#endregion
 
#region Freeze Column
if (ConfigHelper.OPDashboardFrozenColumns > 0)
{
    RadGrid1.ClientSettings.Scrolling.FrozenColumnsCount = ConfigHelper.OPDashboardFrozenColumns;
    RadGrid1.ClientSettings.Scrolling.SaveScrollPosition = true;
}
#endregion
 
#region Resizing
if (ConfigHelper.OPDashboardResize)
{
    RadGrid1.ClientSettings.Resizing.AllowColumnResize = true;
    RadGrid1.ClientSettings.Resizing.ResizeGridOnColumnResize = false;
    RadGrid1.ClientSettings.Resizing.EnableRealTimeResize = true;
}
#endregion
Lydia
Top achievements
Rank 1
 asked on 16 Nov 2011
2 answers
98 views
OK.

This is a bit of a strange one.

I have a page with a tabstrip and multipage control on it.

When one of the tabs is selected, the pageview contains another tab strip with it's own multipage control.

Obviously, when this control shows, the tabs are all 'level one' tabs. Is it possible for me to force the tabs in this inner control to appear like 2nd level tabs?

-- 
Stuart.
Stuart Hemming
Top achievements
Rank 2
 answered on 16 Nov 2011
1 answer
237 views
I have a radgrid that successfully binds to a webservice client side via the <DataBinding> client settings section.  However I would like for the binding to occur based on an event such as a clientside click.  I'm having problems finding info/examples that do this.
Any help would be appreciated.

Thanks,
Pat
Jayesh Goyani
Top achievements
Rank 2
 answered on 16 Nov 2011
1 answer
185 views
HI,

I have a Radgrid(ASP.NET Ajax) with MasterTable and DetailTables.
I have given CommandItemTemplate in MasterTableView. Below is just the part of my code.

 

<telerik:RadGrid runat="server" ID="rgSurvey" AutoGenerateColumns="false" ShowStatusBar="true"

 

 

AllowAutomaticInserts="false" Skin="Outlook" OnItemCommand="rgSurvey_ItemCommand"

 

 

OnPreRender="rgSurvey_PreRender">

 

 

<MasterTableView DataKeyNames="SurveyID" SkinID="Outlook" Width="100%" CommandItemDisplay="Top"

 

 

Name="Survey">
<DetailTables>

 

 

<telerik:GridRelationFields DetailKeyField="SurveyID" MasterKeyField="SurveyID" />

 

 

</ParentTableRelation>

 

 

<CommandItemTemplate>

 

 

<asp:LinkButton ID="lnkAddstaff" runat="server" Text="Add Staff to Survey" CommandName="Popup"></asp:LinkButton>

 

 

</CommandItemTemplate>

 

</telerik:GridTableView>

 

 

</DetailTables>

 

 

<CommandItemTemplate>

 

 

<asp:LinkButton ID="lnkAdd" runat="server" Text="ADD" CommandName="Insert"></asp:LinkButton>

 

 

</CommandItemTemplate>


The CommandItemTemplate [CommandName="Insert"] inside the MAsterTableView is not working.. But the CommandItemTemplate inside DetailTables is working. Not sure why this is happening.

We have a asp.net Master page and Content page(Default.aspx). When using the RadGrid without a master page its working fine.
Are they any known issues when using RadGrid and MAsterTableView inside an asp.net Content page?

Regards,
Dayanithy

 

Shinu
Top achievements
Rank 2
 answered on 16 Nov 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?