[英]How to Get GridView Row Values on ButtonClick using Javascript in asp.net?
I have a GridView
in my asp.net
Applicaiton. 我的
asp.net
应用程序中有一个GridView
。 i have a Button
with javascript
function which shows the values of selected
row in Div
. 我有一个带有
javascript
函数的Button
,它显示Div
中selected
行的值。 How to get all Grid
Column values of Selected Row on ButtonClick
. 如何
Column values of Selected Row on ButtonClick
所有“ Grid
Column values of Selected Row on ButtonClick
。
Javascript:
Javascript:
function SetRowValues(id, controlid, fair, good, mint, nnew, poor,broken) {
//alert(id + " " + fair + " " + controlid);
$("#divSelectedRow").html("TPCCID: " + id + " Fair:" + fair + " Good: " + good + " Mint: " + mint + " New: " + nnew + " Poor: " + poor + " Broken: " + broken);
$("#divSelectedRow").css("display", "block");
return false;
}
Grid Markup: 网格标记:
<asp:TemplateField HeaderText="Source" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center"
HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="BtnSource" runat="server" CausesValidation="false" OnClick='<%# "return SetRowValues("+Eval("ttppcid")+",this.id,"+Eval("Fair")+","+Eval("Good")+","+Eval("Mint")+","+Eval("Poor")+","+Eval("Broken")+")"%>' Text="Source" />
</ItemTemplate>
</asp:TemplateField>
Here, i want to get all the column values of selected row
using Javascript
. 在这里,我想使用
Javascript
获取selected row
所有列值。 Note : When the Value for column1 is string containing Space eg: "Cell Phone" then the script wont work. 注意 :如果column1的值是包含空格的字符串,例如:“手机”,则脚本将无法工作。 Please help me to get the entire
row
values using javascript
on Button Click
. 请帮助我在
Button Click
上使用javascript
获取整个row
值。
Help Appreciated! 帮助赞赏!
I think you have make mistake in preparing the Javascript function call. 我认为您在准备Javascript函数调用时犯了错误。
Missing single quote around parameters '' . 参数''周围缺少单引号。
<asp:TemplateField HeaderText="Source" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center"
HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="BtnSource" runat="server" CausesValidation="false"
OnClick='<%# "return SetRowValues('"+Eval("ttppcid")+"',this.id,'"+Eval("Fair")+"','"+Eval("Good")+"','"+Eval("Mint")+"','"+Eval("Poor")+"','"+Eval("Broken")+"')"%>' Text="Source" />
</ItemTemplate>
</asp:TemplateField>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.