handle button click event inside gridview

2019-09-11 03:43发布

I am writing asp.net project in C#.

The page consists of gridview, it is filled from database initially. The buttons, textboxes and dropdownlists are inside gridview as in the picture picture.

gridview

I want to handle button(сообщить) click event so that I know what row of gridview is clicked in order to get the selected value of dropdowlnist and value of textbox from that row to update the database.

Does someone know how to do this? Thanks!

3条回答
Summer. ? 凉城
2楼-- · 2019-09-11 03:47

you can try e.RowIndex on the event of the btnсообщить_Click

查看更多
Root(大扎)
3楼-- · 2019-09-11 03:48

My first thought is that if you are using the <asp:TemplateField> tags inside your gridview page, then you should be able to register an event in your button code as such: <asp:Button runat="server" OnClick="MyOnClickEvent" />. If you are programmatically adding them, you should be able to use the onClientClick property of the button.

Try reading http://www.codeproject.com/Articles/50540/GridView-Event-Handling. It might point you in the right direction.

查看更多
手持菜刀,她持情操
4楼-- · 2019-09-11 03:49

You can handle the click event of any button type control inside gridview in two ways. The first is through event bubbling, and the second one is directly (in this type of event handling we need to access current girdviewrow container).

I think you should take a look at this article for further knowledge.

How to handle click event of linkbutton inside gridview

查看更多
登录 后发表回答