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

How to Find TextBox ID in RagGrid

3 Answers 227 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ranganath
Top achievements
Rank 1
Ranganath asked on 17 Dec 2008, 01:19 PM

Hi,

 I am using RadGrid  and I designed the UI with Telerik Controls.

I had 3 Text boxes such as “txt_A”,”txt_B” and “txt_C” and I am adding as “txt_A”,”txt_B” values at client side and displaying in to “txt_C”.

In this manner I  have to implement DML Operations(Insertion/Updation). I am successfully inserting record, but come to the point of implementing Update functionality i am getting the problem.

Before Explaining the problem let me explain how I am implementing the TextBox Calculations…

 Iam performing this Operation as follow …

var price = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl02_ctl03_txtResDetailsPrice');

    var txtPriceinsUS = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl02_ctl03_txtPriceinsUS');

Problem

In this manner I have inserted 3 records and now 3 records are Binded to  Grid.

 But while updating the record I am not getting the Control ID as same Above.. here I am getting 3 Id each..for example here I am mentioning the one Control ID as follows while updating 1st record.

       price = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl05_txtResDetailsPrice');

var txtPriceinsUS = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl02_ctl05_txtPriceinsUS');

 

For 2nd Record Updation:-

price = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl07_txtResDetailsPrice');

var txtPriceinsUS = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl02_ctl07_txtPriceinsUS');

so on…

Please help me how to find the Exact ID even while Updating (static ID)..

 

 

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 20 Dec 2008, 12:03 PM
Hello Ranganath,

For your convenience I created an example illustrating how to get the ClientID.

Test it locally and let me know if you need further assistance.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ranganath
Top achievements
Rank 1
answered on 29 Dec 2008, 12:16 PM

The example which u sent not works in my scenario.

Once again I am mentioning my required thing…

 

·         I am using RadGrid  and I designed the UI with Telerik Controls.

I had 3 Text boxes such as “txt_A”,”txt_B” and “txt_C” and I am adding as “txt_A”,”txt_B” values at client side and displaying in to “txt_C”.

In this manner I  have to implement DML Operations(Insertion/Updation). I am successfully inserting record, but come to the point of implementing Update functionality i am getting the problem.

Before Explaining the problem let me explain how I am implementing the TextBox Calculations…

 Iam performing this Operation as follow …

var price = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl02_ctl03_txtResDetailsPrice');

    var txtPriceinsUS = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl02_ctl03_txtPriceinsUS');

Problem

In this manner I have inserted 3 records and now 3 records are Binded to  Grid.

 But while updating the record I am not getting the Control ID as same Above.. here I am getting 3 Id each..for example here I am mentioning the one Control ID as follows while updating 1st record.

       price = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl05_txtResDetailsPrice');

var txtPriceinsUS = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl02_ctl05_txtPriceinsUS');

 

For 2nd Record Updation:-

price = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl07_txtResDetailsPrice');

var txtPriceinsUS = document.getElementById('ctl00_ContentPlaceHolder1_rgRFQResponseDetails_ctl00_ctl02_ctl07_txtPriceinsUS');

so on…

Please help me how to find the Exact ID even while Updating (static ID)..

I designed UI in RadGrid with RadTextboxes. Iam nt at all using Template Columns. In some scenarios I want to get TextBoxIds in TextBox OnBlear Event….

0
Daniel
Telerik team
answered on 05 Jan 2009, 06:58 PM
Hello Ranganath,

These IDs are generated by RadGrid depending on the location of the item in the inner structure of the control. In my previous example I suggested a possible approach on how to get the desired ClientID.

aspx:
<telerik:GridTemplateColumn> 
    <ItemTemplate> 
        Please enter EDIT mode to test this demo 
    </ItemTemplate> 
    <EditItemTemplate> 
        <telerik:RadTextBox ID="RadTextBox1" Text="test" runat="server" /> 
        <asp:Button ID="Button1" runat="server" Text="Click here to get the ClientID of RadTextBox1" 
            OnClientClick="GetID(this)" /> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 

From the parent element (Row, Cell) you can get the required object using the internal findControl method. In the case shown below (an example) we are using the Button object (sender) to get the ClientID of the neighboring RadTextBox:
function GetID(sender)  
    var parent = sender.parentNode; //table cell (a parent element for your button)
    var textBox1 = $telerik.findControl(parent, "RadTextBox1"); 
    alert(textBox1.get_id());  //show the ID

Let me know whether this helps.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Ranganath
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Ranganath
Top achievements
Rank 1
Share this question
or