Gridview批准并拒绝按钮 [英] Gridview approve and reject button
本文介绍了Gridview批准并拒绝按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过在gridview中添加2个按钮批准和拒绝按钮,帮助我尝试在网格视图中更新请求的状态。请帮我怎么做。谢谢
help im trying to update a status of the request in a grid view by adding 2 buttons approve and disapprove button inside the gridview. pls help me how to do it. thanks
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="RequestNo"
DataSourceID="SqlDataSource1">
<columns>
<asp:ButtonField CommandName="Update" Text="Approve" ButtonType="Button" />
<asp:ButtonField ButtonType="Button" Text="Disapprove" />
<asp:BoundField DataField="RequestNo" HeaderText="RequestNo" InsertVisible="False"
ReadOnly="True" SortExpression="RequestNo" />
<asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
<asp:BoundField DataField="FullName" HeaderText="FullName" ReadOnly="True" SortExpression="FullName" />
<asp:BoundField DataField="Position" HeaderText="Position" SortExpression="Position" />
<asp:BoundField DataField="Department" HeaderText="Department" SortExpression="Department" />
<asp:BoundField DataField="Section" HeaderText="Section" SortExpression="Section" />
<asp:BoundField DataField="Employee" HeaderText="Employee" SortExpression="Employee" />
<asp:BoundField DataField="Request" HeaderText="Request" SortExpression="Request" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:BoundField DataField="Comment" HeaderText="Comment" SortExpression="Comment" />
<asp:BoundField DataField="Account" HeaderText="Account" SortExpression="Account" />
</columns>
推荐答案
试试这个样本代码..
Try this sample code..
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="RequestNo" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:ButtonField CommandName="Update" Text="Approve" ButtonType="Button" />
<asp:ButtonField ButtonType="Button" Text="Disapprove" />
<asp:BoundField DataField="RequestNo" HeaderText="RequestNo" InsertVisible="False"
ReadOnly="True" SortExpression="RequestNo" />
<asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
<asp:BoundField DataField="FullName" HeaderText="FullName" ReadOnly="True" SortExpression="FullName" />
<asp:BoundField DataField="Position" HeaderText="Position" SortExpression="Position" />
<asp:BoundField DataField="Department" HeaderText="Department" SortExpression="Department" />
<asp:BoundField DataField="Section" HeaderText="Section" SortExpression="Section" />
<asp:BoundField DataField="Employee" HeaderText="Employee" SortExpression="Employee" />
<asp:BoundField DataField="Request" HeaderText="Request" SortExpression="Request" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:BoundField DataField="Comment" HeaderText="Comment" SortExpression="Comment" />
<asp:BoundField DataField="Account" HeaderText="Account" SortExpression="Account" />
</Columns>
</asp:GridView>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Update")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index]; // row which u have created..
string requestNo = row.Cells[2].Text;
// similarly u can get all the values of the row..
// u can do ur stuff here...
}
if (e.CommandName == "") // other command names etc etc...
{ }
}
此代码会给你一个想法..
看看下面的链接,以便更好地完成工作...
link
[ ^ ]
link
[ ^ ]
这篇关于Gridview批准并拒绝按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文