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

[Solved] UniqueName set to Template column in grid

1 Answer 260 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sreedhar ambati
Top achievements
Rank 1
sreedhar ambati asked on 20 Aug 2009, 05:08 AM
I am having a radgrid. It is having one templatecolumn .
 I assigned a uniquename for that gridtemplate column.
I am having a button outside the grid
On clientclick of that button I am accessing all the rows of the grid.
I could able to read all the rows but in the cellID.innerHTML I am getting 

"<INPUT class=inputsNoExpression id=ctl00_Cont_gvWorkingHours_New_ctl01_ctl04_txtSlotName value=Sree name=ctl00$Cont$gvWorkingHours_New$ctl01$ctl04$txtSlotName> "

My value is Sree
How to get that?

If that column is a bound column then I could able to get the value of the cell by cellId.InnerHTML
but here it is a template column and my unique name was set to that.

Please give the code snippet for accessing the gridtemplate cell value.

My Code:



<asp:Content ID="content" runat="server" ContentPlaceHolderID="Cont">
 
            function AddSlot_New()
            {
                debugger;
                var grid = window["<%= gvWorkingHours_New.ClientID %>"];
         
                 for (var i = 0; i < grid.MasterTableView.Rows.length; i++)  
                 {  
                     var row   = grid.MasterTableView.Rows[i]; 
                     var cellID = grid.MasterTableView.GetCellByColumnUniqueName(row, "txtSlotName");    
                     alert(cellID.innerHTML);
                  }

            }

<rad:RadGrid ID="gvWorkingHours_New" runat="server" Skin="Default" AutoGenerateColumns="false"
             OnNeedDataSource="gvWorkingHours_New_NeedDataSource"  OnItemDeleted="gvWorkingHours_New_ItemDeleted">
               <ClientSettings>
                <Selecting AllowRowSelect="true" />
               </ClientSettings>
                <MasterTableView>
              
                    <Columns>
                   
                        <rad:GridTemplateColumn UniqueName="txtSlotName">
                            <ItemTemplate>
                                <asp:TextBox runat="server" ID="txtSlotName" CssClass="inputsNoExpression" Text='<%# Bind("SlotName") %>'></asp:TextBox>
                            </ItemTemplate>
                        </rad:GridTemplateColumn>

</Columns>
                </MasterTableView>
            </rad:RadGrid>
         
       <asp:Button ID="LinkButton1" runat="server" width="97px" CssClass="sf-inputsLinkButton" OnClientClick="return AddSlot_New()" OnClick="LinkButton1_Click"/>
      

 </asp:Content>


Regards
Sreedhar Ambati

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 20 Aug 2009, 12:10 PM
Hello Sreedhar,

As attached file you can find a sample project demonstrating the required functionality.

I hope this helps

Regards,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
sreedhar ambati
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or