GridView中獲取被點(diǎn)擊行中的DropDownList和TextBox中的值
更新時(shí)間:2013年07月18日 17:49:09 作者:
本文為大家介紹下如何通過點(diǎn)擊GridView中的a標(biāo)簽獲取被點(diǎn)擊行中的下拉框和文本框中的值,具體實(shí)現(xiàn)嗲嗎如下,感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助
aspx頁面代碼:通過點(diǎn)擊GridView中的a標(biāo)簽獲取被點(diǎn)擊行中的下拉框和文本框中的值
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:BoundField HeaderText="ID" DataField="ID" />
<asp:BoundField HeaderText="Name" DataField="ID" />
<asp:BoundField HeaderText="Url" DataField="ID" />
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="0">保密</asp:ListItem>
<asp:ListItem Value="1">男</asp:ListItem>
<asp:ListItem Value="2">女</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<a href="#" onclick="Save(this);">Save</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
jquery代碼:
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function Save(obj) {
var tr = $(obj).parent().parent(); //獲取點(diǎn)擊行的 tr
tr.find("td").eq(3).find("select").val(); //獲取點(diǎn)擊行中的第四列 DropDownList1 的選擇Value
tr.find("td").eq(3).find("select").text(); //獲取點(diǎn)擊行中的第四列 DropDownList1 的選擇Text
tr.find("td").eq(4).find("input").val(); //獲取點(diǎn)擊行中的第四列 TextBox Text
}
</script>
復(fù)制代碼 代碼如下:
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:BoundField HeaderText="ID" DataField="ID" />
<asp:BoundField HeaderText="Name" DataField="ID" />
<asp:BoundField HeaderText="Url" DataField="ID" />
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="0">保密</asp:ListItem>
<asp:ListItem Value="1">男</asp:ListItem>
<asp:ListItem Value="2">女</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<a href="#" onclick="Save(this);">Save</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
jquery代碼:
復(fù)制代碼 代碼如下:
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function Save(obj) {
var tr = $(obj).parent().parent(); //獲取點(diǎn)擊行的 tr
tr.find("td").eq(3).find("select").val(); //獲取點(diǎn)擊行中的第四列 DropDownList1 的選擇Value
tr.find("td").eq(3).find("select").text(); //獲取點(diǎn)擊行中的第四列 DropDownList1 的選擇Text
tr.find("td").eq(4).find("input").val(); //獲取點(diǎn)擊行中的第四列 TextBox Text
}
</script>
相關(guān)文章
ui組件之input多選下拉實(shí)現(xiàn)方法(帶有搜索功能)
這篇文章主要介紹了ui組件之input多選下拉實(shí)現(xiàn)方法(帶有搜索功能)的相關(guān)資料,需要的朋友可以參考下2016-07-07
jQuery通用的全局遍歷方法$.each()用法實(shí)例
這篇文章主要介紹了jQuery通用的全局遍歷方法$.each()用法,結(jié)合實(shí)例形式分析了$.each()方法實(shí)現(xiàn)遍歷功能的相關(guān)技巧,需要的朋友可以參考下2016-07-07
表頭固定(利用jquery實(shí)現(xiàn)原理介紹)
表頭固定應(yīng)該是一個(gè)用得比較多的功能,參考了網(wǎng)上幾個(gè)例子,在幾個(gè)常用瀏覽器下顯示不是很完美2012-11-11
jQuery實(shí)現(xiàn)企業(yè)網(wǎng)站橫幅焦點(diǎn)圖切換功能實(shí)例
這篇文章主要介紹了jQuery實(shí)現(xiàn)企業(yè)網(wǎng)站橫幅焦點(diǎn)圖切換功能,實(shí)例分析了jQuery企業(yè)網(wǎng)站焦點(diǎn)圖的詳細(xì)實(shí)現(xiàn)方法,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2015-04-04
jQuery中delegate和on的用法與區(qū)別詳細(xì)解析
本篇文章主要是對(duì)jQuery中delegate和on的用法與區(qū)別進(jìn)行了詳細(xì)的介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2014-01-01
JQuery表格拖動(dòng)調(diào)整列寬效果(自己動(dòng)手寫的)
當(dāng)鼠標(biāo)停留在表頭邊框線上時(shí),鼠標(biāo)會(huì)變成表示左右拖動(dòng)的形狀,接著拖動(dòng)鼠標(biāo),會(huì)在表格中出現(xiàn)一條隨鼠標(biāo)移動(dòng)的豎線,最后放開鼠標(biāo),表格列寬會(huì)被調(diào)整2014-09-09
jQuery+css實(shí)現(xiàn)的藍(lán)色水平二級(jí)導(dǎo)航菜單效果代碼
這篇文章主要介紹了jQuery+css實(shí)現(xiàn)的藍(lán)色水平二級(jí)導(dǎo)航菜單效果代碼,通過簡(jiǎn)單的jQuery操作鼠標(biāo)事件實(shí)現(xiàn)頁面元素樣式的切換功能,非常美觀大方,需要的朋友可以參考下2015-09-09
使用jquery+iframe做一個(gè)ajax上傳效果(實(shí)例)
下面小編就為大家?guī)硪黄褂胘query+iframe做一個(gè)ajax上傳效果(實(shí)例)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-08-08

