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

[Solved] RadNumericTextBox in GridTemplateColumn not fire event TextChanged

6 Answers 403 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tan
Top achievements
Rank 1
Tan asked on 17 Feb 2012, 11:43 AM
Hello everybody,
As title, I have a RadNumericTextBox as a GridTemplateColumn. Here is my code:
----------------------------------------------------------------------------------------------------------------------
code design
----------------------------------------------------------------------------------------------------------------------
<telerik:RadGrid ID="rgProduct" runat="server" GridLines="None" AutoGenerateColumns="false" 
                        AllowSorting="true" PageSize="3" onneeddatasource="rgProduct _NeedDataSource" 
                        ondeletecommand="rgProduct_DeleteCommand" >
                        
                        <HeaderContextMenu EnableImageSprites="True"></HeaderContextMenu>
                        <MasterTableView>
                        <Columns>
                            <telerik:GridBoundColumn DataField="ProductName" HeaderText="Name" UniqueName="gbcPName">                                   </telerik:GridBoundColumn>                     
                            <telerik:GridBoundColumn DataField="Price" HeaderText="Price" UniqueName="gbcPrice"></telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn HeaderText="Quantity" InitializeTemplatesFirst="false" UniqueName="templatecolumns">
                            <ItemTemplate>
                            <div>
                                <telerik:RadNumericTextBox ID="txtQuantity" ToolTip='<%# Eval("ID") %>' AutoPostBack="true" 
                                                   DataType="System.int16" value='<%# int.Parse(Eval("Quantity").ToString())%>' runat="server" 
                                                   OnTextChanged="TextChanged">
                                </telerik:RadNumericTextBox>
                            </div>
                            </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridButtonColumn Text="Delete" CommandName="Delete" Reorderable="true"></telerik:GridButtonColumn>
                        </Columns>
                        </MasterTableView>
                        </telerik:RadGrid>
----------------------------------------------------------------------------------------------------------------------
code behind
---------------------------------------------------------------------------------------------------------------------- 
public void TextChanged(object sender, EventArgs e)
        {
            RadNumericTextBox ntb = (RadNumericTextBox)sender;
            List<Product> list = (List<Tra>)Session["List"];
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].ID == int.Parse(ntb.ToolTip))
                    list[i].Quantity = (int)ntb.Value;
            }
            Session["List"] = list;
        }
------------------------------------------------------------------------------------------------------------------------
OnTextChanged event doesn't work although I set AutoPostBack="true". 

Greetings
Tan.

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Feb 2012, 01:31 PM
Hello,

I cannot reproduce the issue at my end. Here is the full code that I tried which worked as expected.
aspx:
<telerik:RadGrid ID="grid" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" >
  <MasterTableView>
    <Columns>
      <telerik:GridTemplateColumn>
        <ItemTemplate>
           <telerik:RadNumericTextBox Value='<%# int.Parse(Eval("Quantity").ToString())%>' ID="RadNumericTextBox1" runat="server" AutoPostBack="true"
            ontextchanged="RadNumericTextBox1_TextChanged"></telerik:RadNumericTextBox>
        </ItemTemplate>
   </Columns>
 </MasterTableView>
</telerik:RadGrid>
C#:
protected void RadNumericTextBox1_TextChanged(object sender, EventArgs e)
{
  RadNumericTextBox txt = (RadNumericTextBox)sender;
}

Thanks,
Princy.
0
Tan
Top achievements
Rank 1
answered on 18 Feb 2012, 04:44 AM
Hi Princy, 
I had just solved my problem after I got (HRESUL: 0x80070057 (E_INVALIDARG)) on debug. 
I had more experience. thanks you a lot.

Thanks,
Tan

0
Pooja
Top achievements
Rank 1
answered on 18 Feb 2013, 04:05 PM
hello Tan,

Can you please share how you resolved your issue? I am having same issue. I had it working and then it stopped working all of a sudden. I also tried Autopostback= true. It does post back but the OntextChanged does not get fired.

Thanks
0
Tan
Top achievements
Rank 1
answered on 18 Feb 2013, 04:49 PM
Hello Pooja,
As I said, when I debug my code, I found out (HRESUL: 0x80070057 (E_INVALIDARG)) error. Luckily, I have note this and my resolution is below (I search it with google and I succeed)

(HRESULTL: 0x80070057 (E_INVALIDARG)) on debug

Issue:
When trying to debug an ASP.net website in Visual Studio you get the following error message:

Could not load file or assembly 'your project' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Solution:
Clear out the temporary framework files for your project in: 

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ 

Update: 

For Windows 7, the path is:
C:\Users\[username]\AppData\Local\Temp\Temporary ASP.NET Files\

For 64 bit systems with 'Framework' in the path the full path is:
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\


Good luck to you !!!
0
Pooja
Top achievements
Rank 1
answered on 18 Feb 2013, 05:03 PM
Thanks Tan,

Just found out. I had actually commented out :

If Not PostBack before the Grid binding code..to test why Grid would disappear after I clicked save changes. Put it back and now the updates are fine. Thanks for responding though. Now I have to figure out the issue with grid disappearing after clicking save.

Thanks for your response.

Regards
Pooja
0
Eyup
Telerik team
answered on 21 Feb 2013, 09:28 AM
Hello Pooja,

Please note that performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Paging, Sorting, Filtering require accommodating appropriate database operations. To use them with Simple Databinding you will need to declare custom event handling for every operation which requires binding to your DataSource. Therefore, we strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
Declarative DataSource
Advanced Data Binding

Hope this helps in resolving the disappearing issue.

All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Tan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Tan
Top achievements
Rank 1
Pooja
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or