SelectedIndex auto select on page load
<p>I have an account page where the user can view their account information.. I want them to be able to change their password here. The Way I have managed to implement it it is as follows:</p>

<p>Web service:</p>

<pre><code>[WebMethod]
    public string ChangePassword(DataSet ds)
    {
        string database = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|/dvd_forum.accdb;Persist Security Info=True";
        OleDbConnection myConn = new OleDbConnection(database);
        OleDbDataAdapter myDataAdapter = new OleDbDataAdapter("Select * from Users", myConn);
        OleDbCommandBuilder builder = new OleDbCommandBuilder(myDataAdapter);
        builder.QuotePrefix = "[";
        builder.QuoteSuffix = "]";
        myConn.Open();
        myDataAdapter.Update(ds, "Users");
        myConn.Close();
        return "Password changed!";
    }
</code></pre>

<p>Front code:</p>

<pre><code>&lt;asp:Label ID="username" runat="server" Text=""&gt;&lt;/asp:Label&gt;&lt;span&gt;'s Account&lt;/span&gt;&lt;br /&gt;
&lt;asp:TextBox ID="ChangePasswordInput" runat="server"&gt;&lt;/asp:TextBox&gt;
&lt;asp:Button ID="Button1" runat="server" Text="Save" 
    onclick="ChangePassword_Click" /&gt;
&lt;asp:Label ID="Label2" runat="server" Text=""&gt;&lt;/asp:Label&gt;&lt;asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server" ErrorMessage="Required!" ControlToValidate="ChangePasswordInput"&gt;&lt;/asp:RequiredFieldValidator&gt;
&lt;asp:GridView ID="GridView1" runat="server"&gt;
&lt;/asp:GridView&gt;
</code></pre>

<p>back code:</p>

<pre><code>public partial class Account : System.Web.UI.Page
{

public static DataSet ds;

protected void Page_Load(object sender, EventArgs e)
{
    if (User.Identity.IsAuthenticated)
    {
        username.Text = User.Identity.Name;
    }

    localhost.Service1 myws = new localhost.Service1();
    ds = myws.GetUserAcc(User.Identity.Name);
    GridView1.DataSource = ds;
    GridView1.DataBind();
}
protected void ChangePassword_Click(object sender, EventArgs e)
{
    //change password
    int i = GridView1.SelectedIndex;
    ds.Tables["Users"].Rows[i]["password"] = ChangePasswordInput.Text;
    GridView1.DataSource = ds;
    GridView1.DataBind();
    localhost.Service1 myws = new localhost.Service1();
    Label2.Text = myws.ChangePassword(ds);
}
}
</code></pre>

<p>The problem with this is that I have to select the row in the gridview before changing the password. Is there any way I can have the row automatically selected as there will only ever be one row.. Or how can I code it differently to work without selecting the row first?</p>

<p>Thanks.</p>
