I have defined a SqlDataSource in my ASP code and I am trying to access it from my C# code-behind. I get an error that the source is unknown. What do I have to do so that I can access it from my code-behind?
C# code -
protected void OnEditingGridView1(object sender, GridViewEditEventArgs e)
{
GridViewRow row = GridView1.Rows[e.NewEditIndex];
int index = row.RowIndex;
string ClientKey = GridView1.DataKeys[index].Values["ClientKey"].ToString();
SqlDataSourceDebtor.SelectParameters.Clear();
SqlDataSourceDebtor.SelectParameters.Add("clientKey", ClientKey);
}
ASP code -
<EditItemTemplate>
<asp:DropDownList ID="ddlDebtorName" runat="server"
DataSourceID="SqlDataSourceDebtor" DataTextField="Name"
DataValueField="DebtorKey">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSourceDebtor" runat="server"
ConnectionString="<%$ ConnectionStrings:AuditDevConnectionString2 %>"
SelectCommand="sp_fc_vm_getDebtorList" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" DefaultValue="0" Name="ClientKey"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</EditItemTemplate>