我有一個網格視圖與下面的標記及以下datasourse(存儲查詢LINQ的過程),我增加了刪除和更新命令字段,但我不知道我有什麼樣的代碼添加到刪除和更新這個網格視圖的作品。網格視圖行更新和刪除
<asp:GridView ID="GridViewDocuments_Search" runat="server" AutoGenerateColumns=False Visible="False" onrowcommand="GridViewDocuments_Search_RowCommand"
DataKeyNames="DocID" PageSize="100" >
<Columns>
<asp:TemplateField HeaderText = "Details">
<ItemTemplate>
<asp:Button ID ="btn_Show" Text="Details" runat= "server" CommandName= "Details" CommandArgument='<%#
Container.DataItemIndex%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField DataNavigateUrlFields="Docid,Transid"
DataNavigateUrlFormatString="~/DocResult.aspx?Docid={0}&TransID={1}"
DataTextField="DocumentNo" HeaderText="Doc" />
<asp:BoundField DataField="title" HeaderText="Title" SortExpression="title" />
<asp:BoundField DataField="transmittal" HeaderText="transmittal" SortExpression="transmittal" />
<asp:BoundField DataField="Docid" HeaderText="Docid" Visible="false" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
protected void btnSearch_Click(object sender, EventArgs e)
{
_DataContext = new EDMSDataContext();
var query = _DataContext.spQuickSearch(txtSearchKeywords.Text);
GridViewDocuments.Visible = false;
GridViewDocuments_Search.Visible = true;
GridViewDocuments_Search.DataSource = query;
GridViewDocuments_Search.DataBind();
}
存儲過程spQuickSearch是象下面這樣:
ALTER proc [dbo].[spQuickSearch]
@Searchtext varchar(50)=null
AS
select DocId,TransId,DocumentNo,Title,TRANSMITTAL
from DocumentSum2
where DocumentNo like '%'[email protected] + '%'
or Title like '%'[email protected] + '%'
or TRANSMITTAL like '%'[email protected] + '%'