Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
1.4K+ views
Hi,

I posted this query back in April and then May, and received the following replies:

http://www.telerik.com/community/forums/aspnet/general-discussions/how-to-force-a-gridnumericcolumn-on-a-radgrid-to-accept-integer-values-only.aspx


However, these replies still haven't solved the problem.

I have a grid with 3 columns:
Column 1 - a read only GridBoundColumn which displays a string
Column 2 - an editable GridNumericColumn which displays and accepts an integer value only
Column 3 - an editable GridNumericColumn which displays and accepts an double value only

The editable GridNumericColumn (Columns 2 & 3) will always be in edit mode.
The user can then any value on the editable columns.
However, I am still not able to make Column 2 to accept an integer value only (validation done on the client side) .
Column 3 will only accept a double value only.
When the user clicks the submit button on the page, each value of the editable column will be retrieved and stored on the business object.

Can anybody please help me on how to do this (i.e. to make an editable GridNumericColumn on a grid to accept an integer value)?

You can see the web page on http://www.gouw.ws/radgrid

The code is given below:
ASPX
=====
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="radScriptManager" runat="server" />
        <telerik:RadGrid ID="radGrid" AutoGenerateColumns="false" AllowMultiRowEdit="true" AllowMultiRowSelection="true" GridLines="Vertical" OnItemCreated="radGrid_ItemCreated" OnPreRender="radGrid_PreRender" OnNeedDataSource="radGrid_NeedDataSource" runat="server">
            <ClientSettings>
                <Scrolling UseStaticHeaders="true" />
            </ClientSettings>
            <MasterTableView DataKeyNames="Read" EditMode="InPlace" TableLayout="Fixed">
                <Columns>
                    <telerik:GridBoundColumn DataField="Read" DataType="System.String" HeaderText="Read Only" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" ReadOnly="true" UniqueName="Read" />
                    <telerik:GridNumericColumn DataField="Integer" DataFormatString="{0:N0}" DataType="System.Int32" HeaderText="Integer Only" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" ReadOnly="false" UniqueName="Integer" />
                    <telerik:GridNumericColumn DataField="Dbl" DataFormatString="{0:#,##0.#0}" DataType="System.Double" HeaderText="Double Only" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" ReadOnly="false" UniqueName="Dbl" />
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
    <div align="left">
        <asp:Button ID="button" OnClick="button_Click" Text="Submit" runat="server" />
    </div>
    </form>

ASPX.CS
=======
    public partial class Default : System.Web.UI.Page
    {
        private ArrayList _data = new ArrayList();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                this._data = (ArrayList)Session["DATA"];
            }
            else
            {
                this._data = Data.Load();
                Session["DATA"] = this._data;
            }
        }

        protected void radGrid_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem && e.Item.IsInEditMode)
            {
                RadNumericTextBox numBox = (e.Item as GridDataItem)["Integer"].Controls[0] as RadNumericTextBox;
                numBox.NumberFormat.DecimalDigits = 0;
                numBox.NumberFormat.AllowRounding = false;
                numBox.NumberFormat.KeepNotRoundedValue = true;
            }
        }

        protected void radGrid_PreRender(object sender, System.EventArgs e)
        {
            foreach (GridDataItem item in this.radGrid.Items)
            {
                item.Edit = true;
            }
            this.radGrid.Rebind();
        }

        protected void radGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            this.radGrid.DataSource = this._data;
        }

        protected void button_Click(object sender, EventArgs e)
        {
            // To fetch the editable value on the grid and to store it into the business object
        }
    }

Thanks & regards,
Herman Gouw
Skype: hermangouw
Princy
Top achievements
Rank 2
 answered on 06 Jul 2009
1 answer
167 views

Dear,

 

While I am getting the information from server database and put the data in the radgrid of a page in web browser, I got the error message

see the image.

 A runtime error has occured. Do you wish to debug? line:15

Error: Sys.WebForms.PageRequestMAnagerParseErrorException;

The message received from the server could not be parsed, Common causes for this error are when response is modified by calls to Response.Write(), response filters, HttpModules, or Server trace is enabled.

Details: Error parsing near 'Telerik.Web.UI.2008'.

 

 

What is the reason and I want solution for it as early as possible?

 

Kind Regards,

Surya.

 

 

 

Kind Regards,

Surya.

Princy
Top achievements
Rank 2
 answered on 06 Jul 2009
1 answer
122 views
Hi,

I want to do custom sorting for which I declared my RadGrid in aspx page  as given below:

<telerik:RadGrid AutoGenerateColumns="False" ID="RadGrid1" DataSourceID="SqlDS" AllowFilteringByColumn="true"
            AllowPaging="True" AllowSorting="True" runat="server" Skin="Office2007" OnPageIndexChanged="RadGrid1_PageIndexChanged"
            OnPageSizeChanged="RadGrid1_PageSizeChanged" OnSortCommand="RadGrid_SortCommand">
            <PagerStyle Mode="NextPrevNumericAndAdvanced" />
            <MasterTableView AllowCustomPaging="true" AllowCustomSorting="true">
                <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                <Columns>
                    <telerik:GridBoundColumn SortExpression="RollNo" HeaderButtonType="TextButton"
                        ShowSortIcon="true">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="StudentName" HeaderButtonType="TextButton" ShowSortIcon="true">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="Address" HeaderButtonType="TextButton" ShowSortIcon="true">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
    </telerik:RadGrid>
<asp:SqlDataSource ID="SqlDS" runat="server" ConnectionString="<%$connectionStrings:cemiConnectionString1%>">
</asp:SqlDataSource>

I want to generate GridBoundColumn's at runtime only as I know which columns I need to show at runtime only. so, I removed the three grid bound columns(RollNo,StudentName and Addresss) from design page. When I remove these columns and adding at runtime, postback is not calling onSortCommand event handler(RadGrid_SortCommand). If I add only RollNo gridboundcolumn then postback is calling my sort event handler for only RollNo column, for others(StudentName,Address) it not calling.

Could you please let me know what is the issue???


Thanks,
Mahesh
Shinu
Top achievements
Rank 2
 answered on 06 Jul 2009
1 answer
81 views
Hi All,
    Im using Grid. In Grid when i click add and save button(In Edit Form) immediately the following javascript error thrown.
i dont know how to get out of this bug.

Error:

Microsoft JScript runtime error: Sys.InvalidOperationException: ScriptLoader.loadScripts cannot be called while the ScriptLoader is already loading scripts.



So, Guide me to get out of this bug.......


-Leo        
Shinu
Top achievements
Rank 2
 answered on 06 Jul 2009
3 answers
126 views
Hi
i would like to know why i cant make telerik items visiable once i have declared them visable = false in page load and i would also like to know why i cant rebind to a grid when i have told the grid server side to rebind

Many thanks in advance
Veli
Telerik team
 answered on 06 Jul 2009
6 answers
131 views
hi,

i opened rad window, in this window i have controls etc'.
now, one of the control is button or hyperLink and when i push the button i want to see the result in the parent window no in the current radWindow, and i want to destroy the current window.

some one can help me, how to do this.

thanks in advance,
Udi 
Georgi Tunev
Telerik team
 answered on 06 Jul 2009
1 answer
149 views

Hi

      I am facing the problem in column rezising, i set the all of column width as fixed according to the table data. But the problem once i start to resize the column, it resizes the entire grid, so that i could not get the result as i expected.

I also set the ResizeGridOnColumnResize. But resize works on wothout giving Fixed column width.

Plz clarify me this doubt as soon as possible

Regards,
Appu
Shinu
Top achievements
Rank 2
 answered on 06 Jul 2009
1 answer
109 views
Error:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.



So, i really dont know how to overcome this....

If any one can help me Pls...............



-Leo.
Princy
Top achievements
Rank 2
 answered on 06 Jul 2009
3 answers
214 views
It seems like view state of the controls put in CommandItemTemplate is not maintained. Also changing any of the properties in command event handler does not have any effect on the control. Here is the grid markup

  <telerik:RadGrid ID="NotesGrid" EnableEmbeddedSkins="False" Skin="srunite" Width="100%" 
                AllowSorting="False" AllowPaging="False" AllowMultiRowSelection="False" runat="server" 
                GridLines="None" EnableViewState="true"
                <MasterTableView Width="100%" Summary="RadGrid table" AutoGenerateColumns="False" 
                    CommandItemDisplay="Top" TableLayout="Auto" GroupLoadMode="Client" AllowNaturalSort="false" 
                    AllowSorting="false"
                    <AlternatingItemStyle BackColor="#eeeeee" /> 
                    <CommandItemTemplate> 
                        <div class="gridActions"
                            Notes 
                            <asp:DropDownList ID="cmdFilterNoteType" runat="server" AutoPostBack="false" /> 
                            <asp:LinkButton ID="cmdShowAll" runat="server" AutoPostBack="true" CommandName="ShowAll" 
                                Text="Show All"  Visible="false"/> 
                            <asp:LinkButton ID="cmdShowLatest" runat="server" AutoPostBack="true" CommandName="ShowLatest" 
                                Text="Show Latest"  /> 
                        </div> 
                    </CommandItemTemplate> 


and here are event handlers

      protected void Page_Init(object sender, EventArgs e) 
        { 
            masterPage = (SiteMasterPages.BidModule)Master; 
            presenter.SetModel(masterPage.CurrentBid); 
 
 
            NotesGrid.ItemDataBound += new Telerik.Web.UI.GridItemEventHandler(NotesGrid_ItemDataBound); 
            NotesGrid.ItemCommand += new GridCommandEventHandler(NotesGrid_ItemCommand); 
        } 
 

First problem:
See how I am finding the  LinkButton and making it invisible, or assigning different text but when it renders nothing has changed. I can see it finding the control, I can debug and see that property has been changed, but it still renders these controls as if nothing has changed.  Why?

protected void NotesGrid_ItemCommand(object source, GridCommandEventArgs e)  
        {  
            if (e.CommandName == "ShowLatest")  
            {  
                presenter.ShowLatestNotes();  
                e.Item.FindControl("cmdShowLatest").Visible = false;  
                ((LinkButton)e.Item.FindControl("cmdShowLatest")).Text = "sdasdfdsaf";  
                e.Item.FindControl("cmdShowAll").Visible = true;  
            }  
            else if (e.CommandName == "ShowAll")  
            {  
                presenter.ShowAllNotes();  
                e.Item.FindControl("cmdShowAll").Visible = false;  
                e.Item.FindControl("cmdShowLatest").Visible = true;  
            }  
        }  

Second problem:
I have to rebind the dropdownlist that resides in commanditemtemplate on each postback as it does not maintain the viewstate. Why not?
  protected void NotesGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
            if (e.Item.ItemType == GridItemType.CommandItem) 
            { 
                if (!Page.IsPostBack) 
                { 
 
                    DropDownList filter = e.Item.FindControl("cmdFilterNoteType"as DropDownList; 
                    if (filter != null
                    { 
                        filter.DataSource = _notes.Select(x => x.Key); 
                        filter.DataBind(); 
 
                        filter.Items.Insert(0, new ListItem("All")); 
                    } 
                } 
            } 
            else if (e.Item.ItemType == GridItemType.GroupHeader) 
            { 
                GridTableCell cell = e.Item.Controls[0] as GridTableCell; 
                cell.Attributes.Add("noteType", ((System.Data.DataRowView)e.Item.DataItem).Row.ItemArray[0].ToString()); 
            } 
        } 




Shinu
Top achievements
Rank 2
 answered on 06 Jul 2009
3 answers
618 views
Hi, I have a hierarchical Grid with ShowGroupPanel set to true.  Our specs require that when the users group by a column, both the grouping and the hierarchy for each row inside that group should be collapsed.  I can accomplish the grouping part by setting the GroupsDefaultExpanded property to false, but when users expand each grouping, each underlying row will have its details expanded by default.   HierarchyDefaultExpanded = False only seems to work when no grouping is taking place.   Is there any way I can accomplish this without posting back to the server, either by setting a property to a specific value or through client-side code?   Thank you.
Princy
Top achievements
Rank 2
 answered on 06 Jul 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?