I have an asp.net intranet site hosted on IIS on my computer.
On one page you can enter two user id’s and get a side by side comparison of their roles in our (custom app) system.
I often use it to add roles when I’m setting up new users. After running the query, if i change a role and run the query again it will not show updated results. It’s being cached somehow. I have to go to another page and come back and them run the query to get updated results.
How can avoid having to navigate away to get the updated query results displayed.n
here’s the code
<asp:Label ID="Label1" runat="server" Text="Username"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Username"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server"
Text="Compare Permissions" />
<br /><br />
<asp:GridView ID="GridView1" runat="server" CssClass="mGrid" DataSourceID="SqlDataSource1">
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="WITH
firstPerson AS
(
select username, security_role from user_role
where username=upper(:Username1)
),
secondPerson as
(
select username, security_role from user_role
where username=upper(:UserName2)
)
select firstPerson.username , firstPerson.security_role,secondPerson.username,secondPerson.security_role from firstPerson FULL JOIN secondPerson
on firstPerson.security_role=secondPerson.security_role order by firstPerson.security_role, secondPerson.Security_role">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" Name="Username1"
PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="UserName2"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
I think the problem is simply that after you add these new values, you are not refreshing your gridview. There aren’t any controls that can “automagically realize” the data has changed. Instead, you need to do it manually, by rebinding your data view control to it’s (new) data with
DataBind().