user857521
user857521

Reputation:

Update SqlDataSource SelectCommand Client Side

This is my first attempt at building my own website so apologies in advance if this is a silly question..

I have a gridview which is populated from a SqlDataSource. I also have a control which has AutopostBack=True to update the gridview based on the contents of the control after update.

The code I have so far is (I've changed real field names!)

testPage.aspx:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"   
    AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Lookup"   
    DataSourceID="SqlDataSource1">  
    <Columns>  
        //Column headings removed for clarity 
    </Columns>  
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ 
ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [Field1], [Field2], 
[Field3], [Field4], [Field5], [Field6], [Field7], [Field8] FROM [Analysis] 
 ORDER BY [Field1], [Field2] DESC, [Field3] DESC"></asp:SqlDataSource>

testPage.aspx.cs:

    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();
        }

    }

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?

Can anyone give some pointers on how to make this work client side only so selections in the control don't affect other users?

Upvotes: 0

Views: 1122

Answers (1)

Damith
Damith

Reputation: 63065

if 1 user updates the control, does every other user also see that selection in the gridView when first going to the page?

NO

ASP.net render new pages for each user, changing select command by one user not affect to other users. if you get select command from database or shared file etc.. and update that by one user will see the changes by all others

Upvotes: 1

Related Questions