Imagebutton在Gridview中单击 [英] Imagebutton click in Gridview
本文介绍了Imagebutton在Gridview中单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Gridview中,我在templatefield中添加了一个图像按钮列.当我单击图像按钮时,记录详细信息将显示在另一表格上.一切正常.但是要选择一条记录,我必须双击图像按钮,而不是单击.
如何通过单击图像按钮来获取详细信息?
问候,
Sneha
Hi,
In my Gridview I have added an image button column in templatefield. When I click the image button that record details are displayed on another form. This is working fine. But to select a record, I have to double click image button instead single click.
How can I get details by single click on image button?
Regards,
Sneha
推荐答案
<asp:templatefield xmlns:asp="#unknown">
<itemtemplate>
<asp:button id="AddButton" runat="server">
CommandName="AddToCart"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
Text="Add to Cart" />
</asp:button></itemtemplate>
</asp:templatefield>
protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "AddToCart")
{
// Retrieve the row index stored in the
// CommandArgument property.
int index = Convert.ToInt32(e.CommandArgument);
// Retrieve the row that contains the button
// from the Rows collection.
GridViewRow row = GridView1.Rows[index];
// Add code here to add the item to the shopping cart.
}
}
希望这对您有帮助...
Hope this will help you...
这篇关于Imagebutton在Gridview中单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文