Set a sql selectparameter from code behind in gridview_rowdatabound
<p>I'm building 2 cascading dropdownlists in a gridview edit mode following this example but than in C#:
<a href="http://mikepope.com/blog/DisplayBlog.aspx?permalink=1708" rel="nofollow">http://mikepope.com/blog/DisplayBlog.aspx?permalink=1708</a></p>

<p>But my @AttriFk never gets a value, how can I set this in this event?</p>

<pre><code>&lt;asp:TemplateField HeaderText="Sub Attribute"&gt;
    &lt;EditItemTemplate&gt;
        &lt;asp:DropDownList ID="ddlListSubAttributes" runat="server" AutoPostBack="True" DataSourceID="SqlDataSourceSubAttributes" DataTextField="Title" DataValueField="ID" /&gt;   
        &lt;asp:SqlDataSource ID="SqlDataSourceSubAttributes" runat="server" ConnectionString="Data Source="//empty for this post" ProviderName="System.Data.SqlClient" SelectCommand="SELECT [ID],[Title],[AttriFk] FROM [LocalGTPDatabase].[dbo].[AttributeSubTypes] WHERE ([AttriFk] = @AttriFk)"&gt;
              &lt;SelectParameters&gt;
                    &lt;asp:Parameter Name="@AttriFk" /&gt;
              &lt;/SelectParameters&gt;
         &lt;/asp:SqlDataSource&gt;
    &lt;/EditItemTemplate&gt;
    &lt;ItemTemplate&gt;
        &lt;asp:Label ID="Label66" runat="server" Text='&lt;%# Bind("subAttribute") %&gt;'&gt;&lt;/asp:Label&gt;
   &lt;/ItemTemplate&gt;
&lt;/asp:TemplateField&gt;
</code></pre>

<p>This is a part of my code behind:</p>

<pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowState == DataControlRowState.Edit)
            {
                System.Data.DataRowView dv = (System.Data.DataRowView)e.Row.DataItem;

                DropDownList ddlListAttributes = (DropDownList)(e.Row.FindControl("ddlListAttributes"));
                String nest = Convert.ToString(dv["AttributeFk"]);
                ddlListAttributes.SelectedValue = nest;
                //Databind list of taskCode in dependent drop-down list, preselect value
                DropDownList ddlListSubAttributes = (DropDownList)(e.Row.FindControl("ddlListSubAttributes"));
                SqlDataSource dsc = (SqlDataSource)(e.Row.FindControl("SqlDataSourceSubAttributes"));

                String testing = Convert.ToString(dv["AttributeFk"]);
                //This is not working
                dsc.SelectParameters["@AttriFk"].DefaultValue = Convert.ToString(dv["AttributeFk"]);

                //Than I tried this but still it isn't working:
                dsc.SelectParameters.Add("@AttriFk", Convert.ToString(dv["AttributeFk"])); 

                ddlListSubAttributes.DataBind();
                ddlListSubAttributes.SelectedValue = Convert.ToString(dv["SubAttributeFk"]);
            }
        }
</code></pre>
