Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>How's about replacing the bound field with another template field? Your markup should look like this: <strong>EDIT 2 :</strong> Regarding your second question---</p> <ol> <li><p>I would check my UpdateCommand for the extra lines. I can't see the closed quotation in your command. I have this UpdateCommand <code>UpdateCommand="UPDATE users SET users.roleID = DLookup('[id]','roles', '[role]'=?) WHERE username = ?"</code> and don't have any empty line in debug.</p></li> <li><p>To see the value, you have to get <code>DefaultValue</code> of the parameter like :<code>AccessDataSourceUsers.UpdateParameters[0].DefaultValue</code>.</p></li> </ol> <p><strong>EDIT :</strong> I don't think you can set the parameters in AccessDatasource_Updating. <strong>GridView's RowUpdating</strong> is better place to do this.</p> <pre><code> &lt;asp:GridView ID="GridViewUsers" runat="server" DataSourceID="AccessDataSourceUsers" AllowSorting="True" AutoGenerateColumns="False" AutoGenerateEditButton="True" OnRowUpdating="GridViewUsers_RowUpdating"&gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText="username" SortExpression="username"&gt; &lt;EditItemTemplate&gt; &lt;asp:Label ID="lblUserName" runat="server" Text='&lt;%# Bind("username") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/EditItemTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="lblUserName" runat="server" Text='&lt;%# Bind("username") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText="role" SortExpression="role"&gt; &lt;EditItemTemplate&gt; &lt;asp:DropDownList ID="DropDownListRoles" runat="server" DataSourceID="AccessDataSourceRoles" DataTextField="role" DataValueField="role" SelectedValue='&lt;%# Bind("role") %&gt;'&gt; &lt;/asp:DropDownList&gt; &lt;/EditItemTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Bind("role") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>You can find the label in template field in code:</p> <pre><code>protected void AccessDataSource_Updating(object sender, SqlDataSourceCommandEventArgs e) { // Moved code to the method below } protected void GridViewUsers_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridViewUsers.Rows[GridViewUsers.EditIndex]; var ddl = row.FindControl("DropDownListRoles") as DropDownList; var lblUserName = row.FindControl("lblUserName") as Label; if (ddl != null &amp;&amp; ddl.SelectedValue != null &amp;&amp; lblUserName != null) { AccessDataSourceUsers.UpdateParameters.Add("@role", ddl.SelectedValue); AccessDataSourceUsers.UpdateParameters.Add("@username", lblUserName.Text); AccessDataSourceUsers.Update(); } } </code></pre> <p>I have tested the code above. Hope it helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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