i have web page on which i show user notification from database using grid view with sql datasource.
The problem is when user want to update a record, then addional paramters is send to the database table, that is updateby and updatedon.
here is my code.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ECII(Old)ConnectionString %>" SelectCommand="SELECT * FROM [TblArticles] WHERE (([PublishedBy] = @PublishedBy) AND ([SubcriptionId] = @SubcriptionId)) ORDER BY [ArticleID]" DeleteCommand="DELETE FROM [TblArticles] WHERE [ArticleID] = @ArticleID" InsertCommand="INSERT INTO [TblArticles] ([Title], [Body], [Author], [Categories], [Tags], [PublishedOn], [PublishedBy], [UpdatedOn], [Updatedby], [countlikes], [SubcriptionId]) VALUES (@Title, @Body, @Author, @Categories, @Tags, @PublishedOn, @PublishedBy, @UpdatedOn, @Updatedby, @countlikes, @SubcriptionId)" UpdateCommand="UPDATE [TblArticles] SET [Title] = @Title, [Body] = @Body, [Author] = @Author, [Categories] = @Categories, [Tags] = @Tags, [PublishedOn] = @PublishedOn, [PublishedBy] = @PublishedBy, [UpdatedOn] = @UpdatedOn, [Updatedby] = @Updatedby, [countlikes] = @countlikes, [SubcriptionId] = @SubcriptionId WHERE [ArticleID] = @ArticleID">
<DeleteParameters>
<asp:Parameter Name="ArticleID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Body" Type="String" />
<asp:Parameter Name="Author" Type="String" />
<asp:Parameter Name="Categories" Type="String" />
<asp:Parameter Name="Tags" Type="String" />
<asp:Parameter Name="PublishedOn" Type="DateTime" />
<asp:Parameter Name="PublishedBy" Type="Int32" />
<asp:Parameter Name="UpdatedOn" Type="DateTime" />
<asp:Parameter Name="Updatedby" Type="Int32" />
<asp:Parameter Name="countlikes" Type="Int64" />
<asp:Parameter Name="SubcriptionId" Type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:SessionParameter Name="PublishedBy" SessionField="UserID" Type="Int32" />
<asp:SessionParameter Name="SubcriptionId" SessionField="SubscripID" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Body" Type="String" />
<asp:Parameter Name="Author" Type="String" />
<asp:Parameter Name="Categories" Type="String" />
<asp:Parameter Name="Tags" Type="String" />
<asp:Parameter Name="PublishedOn" Type="DateTime" />
<asp:Parameter Name="PublishedBy" Type="Int32" />
<asp:Parameter Name="UpdatedOn" Type="DateTime" />
<asp:Parameter Name="Updatedby" Type="Int32" />
<asp:Parameter Name="countlikes" Type="Int64" />
<asp:Parameter Name="SubcriptionId" Type="Int32" />
<asp:Parameter Name="ArticleID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<div style="width: 98%; height: 500px; margin: 0 auto; margin-removed 10px; overflow:scroll;">
<asp:GridView ID="GridViewListallarticles" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataKeyNames="ArticleID" DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="Vertical" Width="200%" OnSelectedIndexChanged="GridViewListallarticles_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" />
<Columns>
<%--<asp:BoundField DataField="PublishedBy" HeaderText="PublishedBy" SortExpression="PublishedBy" />--%>
<%--<asp:BoundField DataField="UpdatedOn" HeaderText="UpdatedOn" SortExpression="UpdatedOn" />--%>
<%--<asp:BoundField DataField="Updatedby" HeaderText="Updatedby" SortExpression="Updatedby" />--%>
<%--<asp:BoundField DataField="SubcriptionId" HeaderText="SubcriptionId" SortExpression="SubcriptionId" />--%>
<asp:CommandField HeaderText="Operations" ShowDeleteButton="True" ShowEditButton="True" ShowHeader="True" />
<asp:BoundField DataField="ArticleID" HeaderText="ArticleID" InsertVisible="False" ReadOnly="True" SortExpression="ArticleID" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Body" HeaderText="Body" SortExpression="Body" />
<asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />
<asp:BoundField DataField="Categories" HeaderText="Categories" SortExpression="Categories" />
<asp:BoundField DataField="Tags" HeaderText="Tags" SortExpression="Tags" />
<asp:BoundField DataField="PublishedOn" HeaderText="PublishedOn" SortExpression="PublishedOn" />
<%--<asp:BoundField DataField="PublishedBy" HeaderText="PublishedBy" SortExpression="PublishedBy" />--%>
<asp:BoundField DataField="UpdatedOn" HeaderText="UpdatedOn" SortExpression="UpdatedOn" />
<asp:BoundField DataField="Updatedby" HeaderText="Updatedby" SortExpression="Updatedby" />
<%--<asp:BoundField DataField="SubcriptionId" HeaderText="SubcriptionId" SortExpression="SubcriptionId" />--%>
<asp:BoundField DataField="countlikes" HeaderText="countlikes" SortExpression="countlikes" />
</Columns>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
</asp:GridView>