Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate SqlDataSource SelectCommand Client Side
    text
    copied!<p>This is my first attempt at building my own website so apologies in advance if this is a silly question..</p> <p>I have a gridview which is populated from a <code>SqlDataSource</code>. I also have a control which has <code>AutopostBack=True</code> to update the gridview based on the contents of the control after update.</p> <p>The code I have so far is (I've changed real field names!)</p> <p><strong>testPage.aspx:</strong></p> <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Lookup" DataSourceID="SqlDataSource1"&gt; &lt;Columns&gt; //Column headings removed for clarity &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;" SelectCommand="SELECT [Field1], [Field2], [Field3], [Field4], [Field5], [Field6], [Field7], [Field8] FROM [Analysis] ORDER BY [Field1], [Field2] DESC, [Field3] DESC"&gt;&lt;/asp:SqlDataSource&gt; </code></pre> <p><strong>testPage.aspx.cs:</strong></p> <pre><code> protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { if (ctl04.Value == null) { SqlDataSource1.SelectCommand = "SELECT [Field1], [Field2], [Field3], [Field4], [Field5], [Field6], [Field7], [Field8] FROM [Analysis] ORDER BY [Field1], [Field2] DESC, [Field3] DESC"; } else { SqlDataSource1.SelectCommand = "SELECT [Field1], [Field2], [Field3], [Field4], [Field5], [Field6], [Field7], [Field8] FROM [Analysis] WHERE [Lookup] IN ('" + ctl04.Text.ToString().Replace(",","','") + "') ORDER BY [Field1], [Field2] DESC, [Field3] DESC"; } gridView1.DataBind(); } } </code></pre> <p>So far this works great when testing. However, what I'm unsure about is if say there are multiple users using this page does this cause problems because it's running server side. Eg if 1 user updates the control, does every other user also see that selection in the gridView when first going to the page?</p> <p>Can anyone give some pointers on how to make this work client side only so selections in the control don't affect other users?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload