我把gridview和我添加了超链接以将用户带到其他页面并根据查询更改了状态ID但是更新查询没有工作的问题甚至没有错误:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" style="margin:auto" >
<Columns>
<asp:TemplateField HeaderText="user enter">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# String.Format("~/entry.aspx?request_id={0}",DataBinder.Eval (Container,"DataItem.request_id"))%>' >
enter </asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="name" HeaderText="name" ReadOnly="True" SortExpression="name" />
<asp:BoundField DataField="visitor_mobile" HeaderText="visitor_mobile" SortExpression="visitor_mobile" />
<asp:BoundField DataField="request_id" HeaderText="request_id" InsertVisible="False" ReadOnly="True" SortExpression="request_id" />
<asp:BoundField DataField="request_date" HeaderText="request_date" SortExpression="request_date" />
<asp:BoundField DataField="visit_date" HeaderText="visit_date" SortExpression="visit_date" />
<asp:BoundField DataField="reason" HeaderText="reason" SortExpression="reason" />
<asp:BoundField DataField="status_name" HeaderText="status_name" SortExpression="status_name" />
</Columns>
</asp:GridView>
这是用户点击输入查询以更新status_id
:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:visitormanagementConnectionString %>" SelectCommand="update dbo.requests set status_id=5
where request_id= @request_id;" UpdateCommand="update dbo.requests set status_id=5 where request_id= @request_id">
<SelectParameters>
<asp:QueryStringParameter Name="request_id" QueryStringField="request_id" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="request_id" />
</UpdateParameters>
</asp:SqlDataSource>