How do I pass the SelectedValue of a RadioButtonList to a UpdateParameter in a SqlDataSource from a GridView Control?

How do I pass the SelectedValue of a RadioButtonList to a UpdateParameter in a SqlDataSource from a GridView Control?

this is what I have...
protected void uxChecksGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        RadioButtonList r = (RadioButtonList)uxChecksGridView.Rows[e.RowIndex].FindControl("uxAddAddressRadioButtonList");
        uxChecksSqlDataSource.UpdateParameters["HasAddress"].DefaultValue = r.SelectedValue;
    }
 
    <asp:SqlDataSource ID="uxChecksSqlDataSource" runat="server"
                       ConnectionString="<%$ ConnectionStrings:infonet %>"
                       SelectCommandType="StoredProcedure"
                       SelectCommand="sp_GetDisbursementOfFundsChecksInformation"
                       DeleteCommandType="StoredProcedure"
                       DeleteCommand="sp_DeleteDisbursementOfFundsChecks"
                       InsertCommandType="StoredProcedure"
                       InsertCommand="sp_InsertDisbursementOfFundsChecks"
                       UpdateCommandType="StoredProcedure"
                       UpdateCommand="sp_UpdateDisbursementOfFundsChecks">
        <SelectParameters>
            <asp:SessionParameter Name="DID" SessionField="DID" />
        </SelectParameters>  
        <DeleteParameters>
            <asp:SessionParameter Name="DID" SessionField="DID" />
            <asp:Parameter Name="ID" Type="Int32" />        
        </DeleteParameters>   
        <InsertParameters>
            <asp:Parameter Type="Int32" Name="DID" />
            <asp:Parameter Type="Boolean" Name="CashiersCheck" />          
            <asp:Parameter Type="String" Name="PayableTo" />
            <asp:Parameter Type="Double" Name="Amount" />
            <asp:Parameter Type="String" Name="Purpose" />  
            <asp:Parameter Type="Boolean" Name="HasAddress" />              
            <asp:Parameter Type="String" Name="Address" />
            <asp:Parameter Type="String" Name="City" />
            <asp:Parameter Type="Int32" Name="State" />
            <asp:Parameter Type="String" Name="Zip" />                             
         </InsertParameters> 
         <UpdateParameters>
            <asp:Parameter Name="CashiersCheck" />
            <asp:Parameter Name="PayableTo" />     
            <asp:Parameter Name="Amount" />    
            <asp:Parameter Name="Purpose" />              
            <asp:Parameter Type="String" Name="Address" />
            <asp:Parameter Type="String" Name="City" />
            <asp:Parameter Type="Int32" Name="State" />
            <asp:Parameter Type="String" Name="Zip" />  
            <asp:Parameter Type="Boolean" Name="HasAddress" />
            <asp:SessionParameter Name="DID" SessionField="DID" />
            <asp:Parameter Name="ID" Type="Int32" />                  
         </UpdateParameters>               
    </asp:SqlDataSource>

Open in new window

mmedi005Asked:
Who is Participating?
 
jabcocoCommented:
try
e.Command.Parameters["@HasAddress"].Value = "True";

Open in new window

0
 
jabcocoCommented:
Handle the "OnUpdating" on your sql datasource and set the parameter you need.
.... OnUpdating="uxChecksSqlDataSource_Updating"></asp:SqlDataSource>
 
    protected void uxChecksSqlDataSource_Updating(object sender, SqlDataSourceCommandEventArgs e)
    {
        //Get your radiobuttonlist instance
 
        e.Command.Parameters["CashiersCheck"].Value = r.SelectedValue;
    }

Open in new window

0
 
mmedi005Author Commented:
ok, tried with just manual putting in the value myself...wanted to test without getting the radiobuttonlist.selectedvalue first....

i got this error:

An SqlParameter with ParameterName 'HasAddress' is not contained by this SqlParameterCollection.
    protected void uxChecksSqlDataSource_Updating(object sender, SqlDataSourceCommandEventArgs e)
    {
        e.Command.Parameters["HasAddress"].Value = "True";
    }

Open in new window

0
 
mmedi005Author Commented:
that works, but how do i find the radiobuttonlist from the row im making the update in from the GridView Control?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.