我们可以在asp.net的datagride视图中使用按钮吗?如果是,那么代码是什么? [英] Can we use button in datagride view in asp.net. And if yes what is the code?

查看:60
本文介绍了我们可以在asp.net的datagride视图中使用按钮吗?如果是,那么代码是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需双击它就会为我创建一个函数,然后我将代码写入函数。但是当我双击gridview或它的按钮时,只为我创建了GridView1_SelectedIndexChanged函数,里面的代码不起作用

....

这是我的来源代码:



i just double click on it and a function is created for me and then i write the code to the function. But here when i double click on gridview or its buttons, only GridView1_SelectedIndexChanged function is created for me and the code inside does not work
....
this is my source code:

<asp:BoundField DataField="daysofweek" HeaderText="daysofweek" />
<asp:BoundField DataField="timing" HeaderText="timing" />
<asp:BoundField DataField="fees" HeaderText="fees" />
    <asp:TemplateField>
        <ItemTemplate>
            <asp:Button ID="Buttonid" runat="server" CommandName="Consult now" Text="Consult now" ></asp:Button>    
        </ItemTemplate>
 </asp:TemplateField>





我尝试过:



protected void GridView2_SelectedIndexChanged(object sender,EventArgs e)

{



}



What I have tried:

protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
{

}

推荐答案

抱歉,我们无法为您提供代码,因为您需要编写该代码。我们随时为您解决问题。如果你被困在某个地方,我们很乐意帮助你,但为此,你必须通过提供必要的代码块和其他相关信息来帮助我们。现在,谈到你的观点Gridview有很多事件。请参阅 GridView Events [< a href =https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview_events(v=vs.110).aspx\"target =_ blanktitle =New Window > ^ ]。根据我的理解,您希望在单击行内的按钮时触发事件。为此,您可以查看 RowCommand Event [ ^ ]



希望有所帮助。
Sorry but we can not provide you code since it is you who has to write that. We are here to help you with your problems. If you are stuck somewhere we would be glad to help you but for that you will have to help us help you by providing necessary code blocks and other related information. Now, coming to your point Gridview has a lot of events. See GridView Events[^]. As per my understanding you want to fire an event when the button inside the row is clicked. For that you can check RowCommand Event[^]

Hope that helps.


这篇关于我们可以在asp.net的datagride视图中使用按钮吗?如果是,那么代码是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆