[英]How to update GridView row on button click asp.net c#?
_____________________________
| | |
| Pending Review | (Button) |
|________________|__________|
sample gridview row ^
How can I update this particular row in a gridview
when the button is clicked?单击按钮时,如何在gridview
更新此特定行? As a result the pending review message should display the current time and date.因此,待审核消息应显示当前时间和日期。
<asp:GridView ID="gvProduct"
CssClass="table table-hover table-responsive"
runat="server"
PageSize="15"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
OnPageIndexChanging="gvProduct_PageIndexChanging"
BackColor="White"
BorderColor="#CCCCCC"
BorderStyle="None"
BorderWidth="1px"
CellPadding="3"
ShowHeaderWhenEmpty="true"
EmptyDataText="Product Not Available">
<Columns>
<asp:BoundField DataField="ProductCode"
HeaderText="Product Code" />
<asp:BoundField DataField="ProductName"
HeaderText="Product Name" />
<asp:BoundField DataField="Description"
HeaderText="Description" />
<%-- <asp:BoundField DataField="Type" HeaderText="Type" />--%>
<asp:BoundField DataField="Price"
HeaderText="Price" />
<asp:BoundField DataField="qty"
HeaderText="Qty" />
<asp:BoundField DataField="IsActive"
HeaderText="Status" />
<asp:TemplateField>
<HeaderTemplate>Action</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="lnkEdit"
runat="server"
Font-Underline="false"
CssClass="fa fa-pencil"
OnClick="lnkEdit_Click"
CommandArgument='<%# Eval("ID") %>'></asp:LinkButton> |
<asp:LinkButton ID="lnkdelete"
runat="server"
Font-Underline="false"
CssClass="fa fa-times"
OnClick="lnkDelete_Click"
CommandArgument='<%# Eval("ID") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White"
ForeColor="#000066" />
<HeaderStyle BackColor="#006699"
Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="White"
ForeColor="#000066"
HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999"
Font-Bold="True"
ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
fist of all you bind grid view所有你绑定网格视图的拳头
above code copy in aspx file and use link button and generate link button click event上面的代码复制到aspx文件中并使用链接按钮并生成链接按钮点击事件
protected void lnkEdit_Click(object sender, EventArgs e)
{
LinkButton link = (LinkButton)sender;
long id = Convert.ToInt32(link.CommandArgument);
//find id of data and write update logic
}
this is sample code i hope it's help you这是示例代码,希望对您有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.