通过gridviw中的链接按钮更新数据库 [英] Update Database through a link button from gridviw
问题描述
我正在使用gridview从服务器获取数据.一切正常.我已经使用了&网格视图中有一个链接按钮,因为我希望单击链接按钮时可以执行一些操作.在我的页面中应该会发生:
当某人单击该链接按钮时,postbackurl将把他发送到新的目的地(发生这种情况),并且在单击该按钮时应该更改数据库.
我的gridview看起来像这样
< LAVEL_ID>< LINK_BUTTON>
我想在单击LINK_BUTTON时更改相应LEVEL_ID的数据库信息.因此,我的任务是获取选定的LEVEL_ID,并在单击特定的LINK_BUTTON时进行一些更改.请帮帮我.
你们都是真正的天才.我有很多来自代码项目的代码.
I am using a gridview to get my data from server. Everything is working fine. I have used level & one link button in the grid view because I want some action to get fire when the link button is click. In my page it should happen:
When someone clicks that link button a postbackurl will send him to a new destination (its happening) and there should to be a change in database on the click on the button.
my gridview looks like this
<LAVEL_ID><LINK_BUTTON>
i want to change the information of the database of the corresponding LEVEL_ID when LINK_BUTTON is clicked. So my task is to fetch the selected LEVEL_ID and to do some changes when the particular LINK_BUTTON is clicked. Please help me out.
You all are really Genius. I have many codes from code-project.
Thanks!!
推荐答案
在按钮的OnClick事件中,请执行以下步骤:
In the OnClick event of the button do the next steps:
Button btn = (Button)sender;
GridViewRow row = (GridViewRow)btn.NamingContainer;
GridView.SelectedIndex = row.RowIndex;
现在您可以找到
Now you can find the
level_ID = row.Cells[0].Text;
这篇关于通过gridviw中的链接按钮更新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!