Click here to Skip to main content
15,892,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
I have a Grid Under the  ContentPlaceholder here the grid is Dynamic where it rows will be increasing accordingly to the Values i pass from Database.
On pageload if my Grid contains 5rows for example, i want to get the ID of all the Textbox which is in Grid Dynamically and assign it to the Variable..
How to do it..

When i Run the page and checked view source from browser i got my Textbox name like this

"ctl00_MainContent_gvtemp_ctl00_ctl04_txtDescription"
"ctl00_MainContent_gvtemp_ctl00_ctl06_txtDescription"
"ctl00_MainContent_gvtemp_ctl00_ctl08_txtDescription"
"ctl00_MainContent_gvtemp_ctl00_ctl10_txtDescription"
"ctl00_MainContent_gvtemp_ctl00_ctl12_txtDescription"

I need to Pass those Id to Var ids like below..

var ids = ["ctl00_MainContent_gvtemp_ctl00_ctl04_txtDescription",
                "ctl00_MainContent_gvtemp_ctl00_ctl06_txtDescription",
                "ctl00_MainContent_gvtemp_ctl00_ctl08_txtDescription",
                 "ctl00_MainContent_gvtemp_ctl00_ctl10_txtDescription",
                 "ctl00_MainContent_gvtemp_ctl00_ctl12_txtDescription",
                  "ctl00_MainContent_gvtemp_ctl00_ctl14_txtDescription",
                  "ctl00_MainContent_gvtemp_ctl00_ctl16_txtDescription"];



Here my Grid Coding:

 <telerik:RadGrid ID="gvtemp" AllowSorting="false" AllowPaging="false" runat="server"
                                                    CssClass="grid tBorder" ShowFooter="false" AllowMultiRowSelection="false" AllowMultiRowEdit="false"
                                                    AllowFilteringByColumn="false" CellSpacing="0" CellPadding="0" AutoGenerateColumns="False"
                                                    ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center"
                                                    AlternatingItemStyle-HorizontalAlign="Left" HorizontalAlign="Center">
                                                    <MasterTableView>
                                                        <Columns>
                                                            <telerik:GridTemplateColumn HeaderText="Brand" ItemStyle-Width="3%">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblBrand" runat="server" Text='<%# Bind("BRAND") %>' />
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
                                                            <telerik:GridTemplateColumn HeaderText="Description" ItemStyle-Width="50%" UniqueName="Description">
                                                                <ItemTemplate>
                                                                    <asp:TextBox ID="txtDescription" runat="server" Text='<%# Bind("DESCRIPTION") %>'
                                                                        Height="75px" TextMode="MultiLine" Width="100%"/>
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
                                                        </Columns>
                                                        <EditFormSettings>
                                                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                                            </EditColumn>
                                                        </EditFormSettings>
                                                    </MasterTableView>
                                                   <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_">
                                                    </HeaderContextMenu>
                                                </telerik:RadGrid>
Posted
Updated 26-Aug-15 19:10pm
v2

1 solution

I tried and got the ID of the textbox like

var masterTable = $find("<%= gvtemp.ClientID %>").get_masterTableView();
var row = masterTable.get_dataItems();
var ids = new Array(row);
for (var i = 0; i < row.length; i++) {
var rowid = masterTable.get_dataItems()[i].findElement("txtDescription").id;
ids[i] = rowid;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900