【发布时间】:2019-02-02 16:20:21
【问题描述】:
我想要的是加密使用asp.net Gridview形成的查询字符串。
下面是我的代码
<asp:GridView ID="gvCreatedCRList" runat="server" AutoGenerateColumns="False" CssClass="table table-bordered table-hover"
ShowHeaderWhenEmpty="True" PageSize="10" AllowPaging="true" EmptyDataText="No data to display.">
<Columns>
<asp:HyperLinkField DataTextField="CHANGEREQUESTNUMBER" ItemStyle-CssClass="GridRow"
HeaderText="Change Request No" DataNavigateUrlFields="CHANGEREQUESTID" DataNavigateUrlFormatString="ChangeRequestDetails.aspx?ID={0}"
Text="CR No" Target="_blank" ItemStyle-Width="11%" />
<asp:BoundField DataField="DESCRIPTION" ItemStyle-CssClass="GridRow" HeaderText="Description"
ReadOnly="True" ItemStyle-Width="15%" />
<asp:BoundField DataField="STATENAME" ItemStyle-CssClass="GridRow" HeaderText="State"
ReadOnly="True" SortExpression="State" ItemStyle-Width="12%" />
<asp:BoundField DataField="CITYNAME" ItemStyle-CssClass="GridRow" HeaderText="City"
ReadOnly="True" SortExpression="City" ItemStyle-Width="7%" />
<asp:BoundField DataField="CATEGORY" ItemStyle-CssClass="GridRow" HeaderText="Category"
ReadOnly="True" SortExpression="Category" ItemStyle-Width="7%" />
<asp:BoundField DataField="CHANGETYPE" ItemStyle-CssClass="GridRow" HeaderText="Type"
ReadOnly="True" SortExpression="Type" ItemStyle-Width="15%" />
<asp:BoundField DataField="OPENCLOSED" ItemStyle-CssClass="GridRow" HeaderText="Open/ Closed"
ReadOnly="True" ItemStyle-Width="4%" />
<asp:BoundField DataField="STATUS" ItemStyle-CssClass="GridRow" HeaderText="Detailed Status"
ReadOnly="True" ItemStyle-Width="15%" />
<asp:BoundField DataField="CREATEDON" ItemStyle-CssClass="GridRow" HeaderText="Creation Date"
ReadOnly="True" DataFormatString="{0:dd-MM-yyyy}" ItemStyle-Width="7%" />
<asp:BoundField DataField="LASTMODIFIEDON" ItemStyle-CssClass="GridRow" HeaderText="Last Modified Date"
ReadOnly="True" DataFormatString="{0:dd-MM-yyyy}" ItemStyle-Width="7%" />
</Columns>
<HeaderStyle BackColor="#C3C1C1" />
<RowStyle HorizontalAlign="Left" />
<PagerStyle CssClass="pagergrid" />
</asp:GridView>
我要加密DataNavigateUrlFormatString="ChangeRequestDetails.aspx?ID={0}"
【问题讨论】:
-
只需使用
NavigateUrl='<%# this.ResolveUrl(string.Format("ChangeRequestDetails.aspx?ID={0}", Decrypt(Eval("CHANGEREQUESTID").ToString()))) %>'。 (Decrypt是自定义加密方法名称示例)。 -
@TetsuyaYamamoto:你好,但我想首先它需要加密吧?
-
当然在
ResolveUrl可以使用加密ID之前它应该被加密。 -
我收到构建错误
Error 2 Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.HyperLinkField does not have a DataBinding event. D:\Username\CMP\CMP\CMPNew CR PDF\ChangeRequestApplication\Homepage.aspx 172 -
代替
HyperLinkField,尝试用HyperLink填充的ItemTemplate,其中Eval表达式效果很好。
标签: c# asp.net encryption query-string