动态获取文本框的ID并分配给变量

编程入门 行业动态 更新时间:2024-10-24 02:01:48
本文介绍了动态获取文本框的ID并分配给变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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>

推荐答案

我试过并获得文本框的ID,如 var masterTable = 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;我< row.length; i ++){ var rowid = masterTable.get_dataItems()[i] .findElement(txtDescription)。id; ids [i] = rowid; } 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; }

更多推荐

动态获取文本框的ID并分配给变量

本文发布于:2023-11-10 00:45:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573903.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   文本框   动态   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!