我们可以在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 [ ^ ]。根据我的理解,您希望在单击行内的按钮时触发事件。为此,您可以查看 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.