且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在网格视图中使用update命令发送更多参数

更新时间:2023-12-04 20:05:16

ConnectionStrings:ECII(旧)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],[标签],[PublishedOn],[PublishedBy],[UpdatedOn],[Updatedby],[countlikes],[SubcriptionId])VALUES(@Title,@ Body,@ Author,@ Category,@ Tags,@ PostlishedOn,@ PububyBy, @UpdatedOn,@ Updatedby,@ countlikes,@ SubscriptionId) UpdateCommand = UPDATE [TblArticles] SET [Title] = @Title,[Body] = @ Body,[作者] = @Author,[类别] = @Categories,[TagsOn] = @Tags,[PublishedBy] = @PublishedBy,[UpdatedOn] = @UpdatedOn,[Updatedby] = @Updatedby,[countlikes] = @countlikes,[SubcriptionId ] = @SubcriptionId WHERE [ArticleID] = @ArticleID >
< DeleteParameters>
< asp:参数名称= ArticleID Type = Int32 />
< / DeleteParameters >
< InsertParameters>
< asp:参数名称= 标题类型= String />
< asp:参数名称= 正文类型= String />
< asp:参数名称= 作者类型= String />
< asp:参数名称= 类别类型= String />
< asp:参数名称= 标签 Type = String />
< asp:参数名称= PublishedOn Type = DateTime />
< asp:参数名称= PublishedBy Type = Int32 />
< asp:参数名称= UpdatedOn Type = DateTime />
< asp:参数名称= 更新为 Type = Int32 />
< asp:参数名称= countlikes Type = Int64 />
< asp:参数名称= SubcriptionId Type = Int32 />
< / InsertParameters >
< SelectParameters>
< asp:SessionParameter Name = PublishedBy SessionField = UserID Type = Int32 />
< asp:SessionParameter Name = SubcriptionId SessionField = SubscripID Type = Int32 />
< / SelectParameters >
< UpdateParameters>
< asp:参数名称= 标题类型= String />
< asp:参数名称= 正文类型= String />
< asp:参数名称= 作者类型= String />
< asp:参数名称= 类别类型= String />
< asp:参数名称= 标签 Type = String />
< asp:参数名称= PublishedOn Type = DateTime />
< asp:参数名称= PublishedBy Type = Int32 />
< asp:参数名称= UpdatedOn Type = DateTime />
< asp:参数名称= 更新为 Type = Int32 />
< asp:参数名称= countlikes Type = Int64 />
< asp:参数名称= SubcriptionId Type = Int32 />
< asp:参数名称= 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 = 白色 BorderColor = #DEDFDE BorderStyle = BorderWidth = 1px CellPadding = 4 DataKeyNames = ArticleID DataSourceID = SqlDataSource1 ForeColor = 黑色 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 /&gt ; - %>
<% - < asp:BoundField DataField = 更新 HeaderText = 更新 SortExpression = 更新 /> - %>
&lt ;% - < asp:BoundField DataField = SubcriptionId HeaderText = SubcriptionId SortExpression = SubcriptionId /> - %>
< asp:CommandField HeaderText = 操作 ShowDeleteButton = True ShowEditButton = True ShowHeader = True />
< asp:BoundField DataField = ArticleID HeaderText = ArticleID InsertVisible = False ReadOnly = True SortExpression = ArticleID />
< asp:BoundField DataField = 标题 HeaderText = 标题 SortExpression = 标题 />
< asp:BoundField DataField = Body HeaderText = 正文 SortExpression = 身体 />
< asp:BoundField DataField = 作者 HeaderText = 作者 SortExpression = 作者 />
< asp:BoundField DataField = 类别 HeaderText = 类别 SortExpression = 类别 />
<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>
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>


Hi Muhammad Taqi Hassan Bukhari



In gridview there are various types of events before and after.





Here you need...



RowUpdating: Is raised before a GridView updates a record, which means that the row’s update button has been clicked but before the GridView updates the row.





Follow this link you will get answer.



http://www.c-sharpcorner.com/uploadfile/00c99e/gridview-events-for-beginners/[^]





Let me know if you have any furt her query.

Please, go through above suggestion.

If its your answer, please mark as solution.

Best of luck for hunting solutions.



Thank you.

Regards,

Manoj Kalla
Hi Muhammad Taqi Hassan Bukhari

In gridview there are various types of events before and after.


Here you need...

RowUpdating: Is raised before a GridView updates a record, which means that the row's update button has been clicked but before the GridView updates the row.


Follow this link you will get answer.

http://www.c-sharpcorner.com/uploadfile/00c99e/gridview-events-for-beginners/[^]


Let me know if you have any further query.
Please, go through above suggestion.
If its your answer, please mark as solution.
Best of luck for hunting solutions.

Thank you.
Regards,
Manoj Kalla