locked
Set null value to SqlDataSource Insert Parameter RRS feed

  • Question

  • User-1339422861 posted

    hi all

    this is my html code

     

    <InsertParameters>
            <asp:QueryStringParameter Name="ProjectID" QueryStringField="PID" Type="String" DefaultValue="1" />
            <asp:ControlParameter ControlID="rblQuestion1" Name="Question1" PropertyName="SelectedValue"
                Type="Int32" />
            <asp:ControlParameter ControlID="rblQuestion2" Name="Question2" PropertyName="SelectedValue"
                Type="Int32" />
    <asp:ControlParameter ControlID="txtOpinion" Name="Opinion" PropertyName="Text" Type="String" />
            <asp:Parameter Name="RETURN_VALUE" Type="Int32" Direction="ReturnValue" />
        </InsertParameters>

     

    i need to set null value to SqlDataSource Insert Parameter at runtime

    i am used this code

    for (int Index = 1; Index <= 2; Index++) { sdsMedicoFeedback.InsertParameters["Question" + Index.ToString()].DefaultValue = null; } sdsMedicoFeedback.Insert();but it's not working

    
    

     

     

     

     

     

    Tuesday, December 21, 2010 3:22 AM

All replies

  • User191633014 posted

    add ConvertEmptyStringToNull="true" to Parameters:

    <asp:ControlParameter ConvertEmptyStringToNull="true"   ControlID="rblQuestion1" Name="Question1" PropertyName="SelectedValue" Type="Int32" />

    and set DefaultValue = string.Empty;

    for (int Index = 0; Index <= 1; Index++)

    { sdsMedicoFeedback.InsertParameters[Index].DefaultValue = string.Empty; }

    Tuesday, December 21, 2010 5:07 AM
  • User-1418680850 posted

    Hi,

    Try this

    for (int Index = 1; Index <= 2; Index++)

    { sdsMedicoFeedback.InsertParameters["Question" + Index.ToString()].DefaultValue = System.DBNull.Value;

    }

    sdsMedicoFeedback.Insert()

    Friday, December 24, 2010 4:48 AM
  • User-1339422861 posted

    no it's not working

    this is my web user control

    please look at this 

    http://rapidshare.com/files/439092532/Medico.rar

     

    Friday, December 24, 2010 3:00 PM
  • User-1812063630 posted

    Hi,

    Try this

    for (int Index = 1; Index <= 2; Index++)

    {

    sdsMedicoFeedback.InsertParameters["Question" + Index.ToString()].DefaultValue = "";

    }

    sdsMedicoFeedback.Insert();

     


    Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.

     

    Wednesday, December 29, 2010 12:06 AM
  • User-1339422861 posted

    nio it's not working 

    Wednesday, December 29, 2010 12:53 AM