
在选择事件中用GridView1SelectedRowFindControl(按钮ID)来查找按钮。
或者给选择按钮加CommandArgument和CommandName参数用来传递名和参数更方便一些。
给你点提示,
gridview有一个OnRowCreated事件,如:
protected void gridview_RowCreated(object sender, GridViewRowEventArgs e)
{
if (eRowRowType == DataControlRowTypeDataRow)
{
if (SelectGroupSelectedIndex == eRowRowIndex)
{
}
}
}
在这个例子里,eRowRowIndex就是行号
<form name="form1" method="post" action="indexasp">
<input name="sex" type="radio" value="男" checked>
男
<input type="radio" name="sex" value="女">
女
<input type="submit" name="Submit" value="提交">
</form>
indexasp
sex=trim(request("sex"))'这里就是获取单选按钮的值
<html>
<head>
</head>
<body>
<input type='button' value='9' onclick='GetValue(this)'>
<input type='button' value='8' onclick='GetValue(this)'>
<input type='button' value='7' onclick='GetValue(this)'>
<input type='button' value='6' onclick='GetValue(this)'>
<span id="showValue"></span>
<script>
function GetValue(obj)
{
documentgetElementById("showValue")innerHTML += objvalue;
}
</script>
</body>
</html>
<input type="radio" name="gender" value="男" checked="checked"/>男
<input type="radio" name="gender" value="女"/>女
/
@see 获得性别
@return String
/
function getSex(){
var value="";
var radio=documentgetElementsByName("gender");
for(var i=0;i<radiolength;i++){
if(radio[i]checked==true){
value=radio[i]value;
break;
}
}
return value;
}
首先,我需要可以通过tagName获取所有的按钮,对你的按钮添加监听事件;
代码如下:
html:
<div id="butDIv">
<button id="1">121</button>
<button id="2">22</button>
<button id="3">222</button>
<button id="4">2222</button>
</div>
js代码:
var tempDiv=documentgetElementById('butDIv');
var teBut=tempDivgetElementsByTagName('button');
for(var i=0;i<teButlength;i++){
teBut[i]onclick=function(){
consolelog(thisid);
}
}
给按钮添加 CommandArgument='<%#Eval("uId") %>' 属性
在点击事件中 通过 ((LinkButton)sender)CommandArgument) 来获取
以上就是关于GridView中如何获取选择按钮的ID值全部的内容,包括:GridView中如何获取选择按钮的ID值、GridView 如何取选择按钮行的值、asp 如何获取单选按钮组中的值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)