Solved

required field validator for databound dropdownlist

Posted on 2010-08-30
10
1,608 Views
Last Modified: 2013-11-27
Hello,

I have a web application built using VS 2005 and C#.  There is a dropdown control bound to a database table using a dataset as follows:
-----------
<asp:DropDownList ID="ddl_ICLU_Specify" runat="server" SelectedValue='<%# Bind("ICLU_Specify") %>' AutoPostBack="false" DataSourceID="ds_LU_ICLU" DataTextField="LU_CODE_Desc" DataValueField="LU_CODE_Desc" AppendDataBoundItems="true">  

 </asp:DropDownList>
                                                   
            <asp:SqlDataSource id="ds_LU_ICLU" runat="server" ConnectionString="<%$ ConnectionStrings:RLUISConnectionString %>" SelectCommand="SELECT [LU_CODE_Desc] FROM [RLUIS_LU]"></asp:SqlDataSource>                                      
                                                   
                                                   
                                                    &nbsp;<span style="color:Red">*</span>
<asp:RequiredFieldValidator ID="RFV_ICLU_Specify" runat="server" ErrorMessage="Please Select" ControlToValidate="ddl_ICLU_Specify" InitialValue=" " Display="dynamic" Enabled="false"></asp:RequiredFieldValidator>
--------
I am attempting to validate that if the user has the web application display "Please Select" on the ddl control, the database entry is a "null" rather than "Please Select"

Right now, the RequiredFieldValidator does not seem to validate against the ddl control's data source, where the first choice is "Please Select"

Again, I just want to have the code enter a " " value into the database table rather than "Please Select"

Please help...
0
Comment
Question by:Codeaddict7423
  • 5
  • 4
10 Comments
 
LVL 6

Expert Comment

by:thaytu888888
ID: 33563855
- Just add my validator below:
<asp:RegularExpressionValidator ID="regTest" runat="server" ValidationExpression="[^Please Select]" ControlToValidate="ddl_ICLU_Specify"></asp:RegularExpressionValidator>

- And when you clicked the submit button, before insert to database, add the codes below:
if (ddl_ICLU_Specify.Items.Count > 0)
        {
            foreach (ListItem li in ddl_ICLU_Specify.Items)
            {
                if (li.Value == "Please Select")
                {
                    li.Value = "";
                }
            }
        }
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 33564550
If you have first choice available as "Please select" then youcan put it as initial value in Required field validator as below:

<asp:RequiredFieldValidator ID="RFV_ICLU_Specify" runat="server" ErrorMessage="Please Select" ControlToValidate="ddl_ICLU_Specify"  InitialValue="Please Select " Display="dynamic" Enabled="false"></asp:RequiredFieldValidator>

else
After binding datasource to the Dropdownlist you can insert "Please Select" as first item and then set the Intial value in Required field validator as mentioned above. You can insert item as below :

ddl_ICLU_Specify.Items.Insert(0, new ListItem("Please Select","Please Select");

Hope this will work for you.
Regards,
Ram
0
 

Author Comment

by:Codeaddict7423
ID: 33566533
ramkisan,
Thank you for the quick reply. I implemented your suggestion and indeed, now the validator works for the ddl data source and does not  submit when "please select" is displayed as a choice.

However, the choice "please select" is still being added to the database table. Now, i'd like to know how to code your suggestion such that instead of "please select", there is a " " value added to the database table.
Thank you in advance.
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 33566577
For this purpose you can set value for please select item as " " and set the initial value of the Required filed validator as " "  too, so that whenever you select "Please Select" it will put its value as " " .

Hope this will help you.
Regards,
Ram
0
 

Author Comment

by:Codeaddict7423
ID: 33566732
ramkisan,
Thank yoiu for your quick reply. i can see how to change the value of the requiredfieldvalidator to " " but i'm a bit confused in how to 'set value for please select item as " " '

I'm pulling the values for the ddl from a sql database table. in  this table, i have a column called  LU_Desc. this column has the description of the text displayed as choices in the ddl_ICLU_Specify.  How can I set this value as " " and still show "please select"
Thank you in advance
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 33566784
ddl_ICLU_Specify.Items.Insert(0, new ListItem("Please Select"," ");

By this you can add  item "Please Select" with " " value.

Still u r not able to do that can you please share urn code?
I am available for next 15 mins.

Regards,
Ram
0
 

Author Comment

by:Codeaddict7423
ID: 33566800
ramkisan,
Below, please find my code.
----------
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>GIS Land Use Test Default</title>
   
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
   
    <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>

   
<!-- This function takes an array of the ddl Ids and set the selected index of the ddl to 0 i.e. the first item ("Please Select")-->

   
    <script type="text/JavaScript">

  function toggle(chb,target,validatorsArray,ddlarray)
 {
       if (chb.checked == false) {
            for (i = 0; i < ddlarray.length; i++) {
                var vid = $("[id$='_" + ddlarray[i] + "']").attr('id');
                var val = document.getElementById(vid);
                val.selectedIndex = 0;
            }
           // window.location.reload();
         }  

      obj=(document.all) ? document.all[target] : document.getElementById(target);
      obj.style.display = (obj.style.display == 'none') ? 'inline' : 'none';
      var enable = true;
      if (obj.style.display == 'none') {
          enable = false;
      }
    var i = 0;
        for (i = 0; i < validatorsArray.length; i++) {
            var vid = $("[id$='_" + validatorsArray[i] + "']").attr('id');
            val = document.getElementById(vid)
            ValidatorEnable(val, enable);
        }
}

 function textboxMultilineMaxNumber(txt,maxLen){  
            try{  
                if(txt.value.length > (maxLen-1))
                return false;  
               }catch(e){  
               }  
        }  


</script>

    <!--after this, the function call from the textbox (<input type="checkbox" id="chk_ICLU" name="chk_ICLU" onclick="toggle(this,'therow',['RFV_ICLU_Correction','RFV_ICLU_Specify'],['ddl_ICLU_Correction','ddl_ICLU_Specify'] )" /> takes the array of the ddls and reindexes them to 0 so when the checkbox is de-selected (chb.checked == false), it fires first and the code that opens up the table row adn displays the panel (panel1, panel2, panel3) gives the user choices.
      -->
   
   
</head>
<body style="background-color:#1c2a09" >
    <form id="form1" runat="server">
   
    <div style="text-align:left">
        <img src="images/logo.jpg" alt="logo"/>
   
    <table width="80%" cellpadding="5" cellspacing="0"  border="1" bordercolor="#1c2a09" style="background-color:#FFFFFF;border: solid; border-color: #1c2a09; height: 500px;">
        <tr><td><h2 style="background-color:#FFFFFF;font-size:14pt"> Feedback Form</h2>
            &nbsp;Fields marked with an <span style="color:Red;background-color:#FFFFFF">*</span> are required.
            <br />
        </td></tr>
        <tr>
            <td style="width:100%" valign="top" align="left">
                <asp:FormView Width="100%" ID="FormView1" runat="server" DataKeyNames="INPUTID" DataSourceID="ds_RLUIS1" DefaultMode="Insert" Font-Names="Arial" Font-Size="10pt" AllowPaging="false" BackColor="white" BorderColor="white" BorderWidth="0px" CellPadding="2" >
                    <InsertItemTemplate>
                        <table cellpadding="1" cellspacing="0" border="0">
                            <tr>
                                <td style="width:30%; text-align:right; vertical-align:top; background-color:#F0F0F0;font-weight:bold "><asp:Label ID="INPUTIDLabel" runat="server" Text="Parcel ID:"></asp:Label>&nbsp;&nbsp;&nbsp;</td>
                                <td style="width:70%;background-color:#F0F0F0;font-weight:bold;font-size:10pt">
                                    <asp:TextBox ID="ParcelIDTextBox" runat="server" style="font-weight:bold;background-color:#F0F0F0" Text='<%# Bind("ParcelID") %>' ReadOnly="true" BorderWidth="0"></asp:TextBox>
                                    <br /><br />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right; white-space: nowrap; width: 30%">&nbsp;&nbsp;&nbsp;&nbsp;</td>
                                <td style="text-align: left; white-space: nowrap; width: 25%"><span>
                                    <span style="font-weight:normal; color:Red" > Tell us what you think needs to be changed or included: (check all that apply) </span>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right; white-space: nowrap; width: 30%" valign="top"><asp:Label ID="Label1" runat="server" Text="Incorrect Current Land Use"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;</td>
                                <td style="text-align: left; white-space: nowrap; width: 25%">
                       <input type="checkbox" id="chk_ICLU" name="chk_ICLU" onclick="toggle(this,'therow',['RFV_ICLU_Correction','RFV_ICLU_Specify'],['ddl_ICLU_Correction','ddl_ICLU_Specify'] )" />
                                    <!--Incorrect Current Land Use Panel -->
                                    <div id="therow" style="display:none">
                                    <asp:Panel ID="Panel1" runat="server" Visible="true">
                                        <table cellpadding="5" cellspacing="0" border="0" bgcolor="#F0F0F0">  
                                            <tr>
                                                <td style="width:30%; text-align:left; vertical-align:top"><asp:Label ID="Label4" runat="server" Text="Basis for Correction:"></asp:Label><br /></td>
                                                <td style="width:70%; text-align:left; vertical-align:top">
                                                    <asp:DropDownList ID="ddl_ICLU_Correction" runat="server" SelectedValue='<%# Bind("ICLU_Correction") %>' AutoPostBack="false">
                                                    <asp:ListItem Value=" " Text="Please Select" Selected="true">Please Select</asp:ListItem>
                                                    <asp:ListItem Value="Inconsistent with Imagery" Text="Inconsistent with Imagery">Inconsistent with Imagery</asp:ListItem>
                                                    <asp:ListItem Value="Personal Knowledge of Area" Text="Personal Knowledge of Area">Personal Knowledge of Area&nbsp;&nbsp;&nbsp;&nbsp;</asp:ListItem>
                                                    </asp:DropDownList>&nbsp;<span style="color:Red">*</span>

<asp:RequiredFieldValidator ID="RFV_ICLU_Correction" runat="server" ErrorMessage="Please Select" ControlToValidate="ddl_ICLU_Correction" InitialValue=" " Display="dynamic" Enabled="false"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="width:30%; text-align:left; vertical-align:top"><asp:Label ID="Label6" runat="server" Text="Specify Correct Current Land Use:"></asp:Label>&nbsp;<br /> </td>
                                                <td style="width:70%; text-align:left; vertical-align:top">    
            <asp:DropDownList ID="ddl_ICLU_Specify" runat="server" SelectedValue='<%# Bind("ICLU_Specify") %>' AutoPostBack="false" DataSourceID="ds_LU_ICLU" DataTextField="LU_CODE_Desc" DataValueField="LU_CODE_Desc" AppendDataBoundItems="true" CausesValidation="true">  

 </asp:DropDownList>
                                                   
            <asp:SqlDataSource id="ds_LU_ICLU" runat="server" ConnectionString="<%$ ConnectionStrings:RLUISConnectionString %>" SelectCommand="SELECT [LU_CODE_Desc] FROM [RLUIS_LU]"></asp:SqlDataSource>                                      
                                                                                           
                                                    &nbsp;<span style="color:Red">*</span>

<asp:RequiredFieldValidator ID="RFV_ICLU_Specify" runat="server" ErrorMessage="Please Select" ControlToValidate="ddl_ICLU_Specify"  InitialValue=" " Display="dynamic" Enabled="false"></asp:RequiredFieldValidator>
                       
                       
                                                </td>
                                            </tr>
                                        </table>    
                                    </asp:Panel>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right; white-space: nowrap; width: 30%; background-color:#FFFFFF" valign="top"><asp:Label ID="Label2" runat="server" Text="Incorrect Future Land Use"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;</td>
                                <td style="text-align: left; white-space: nowrap; width: 25%">
                                    <input type="checkbox" id="chk_IFLU" name="chk_IFLU" onclick="toggle(this,'therow02',['RequiredFieldValidator_IFLU_Specify'],['ddl_IFLU_Specify'] )" />
                                    <!--Incorrect Future Land Use  Panel -->
                                    <div id="therow02" style="display:none">
                                    <asp:Panel ID="Panel2" runat="server">
                                        <table cellpadding="5" cellspacing="0" border="0" bgcolor="#F0F0F0">
                                            <tr>
                                                <td style="width:30%"><asp:Label ID="Label5" runat="server" Text="Specify Correct Future Land Use:"></asp:Label>&nbsp;&nbsp;<br /> </td>
                                                <td style="width:70%">
                                                    <asp:DropDownList ID="ddl_IFLU_Specify" runat="server" SelectedValue='<%# Bind("IFLU_Specify") %>' AutoPostBack="false" DataSourceID="ds_LU_IFLU" DataTextField="LU_CODE_Desc" DataValueField="LU_CODE_Desc"></asp:DropDownList>
       
        <asp:SqlDataSource ID="ds_LU_IFLU" runat="server" ConnectionString="<%$ ConnectionStrings:RLUISConnectionString %>" SelectCommand="SELECT [LU_CODE_Desc] FROM [RLUIS_LU]"></asp:SqlDataSource>
 
 
 
&nbsp;<span style="color:Red">*</span>

 
  <asp:RequiredFieldValidator ID="RequiredFieldValidator_IFLU_Specify" runat="server" ErrorMessage="Please Select" ControlToValidate="ddl_IFLU_Specify"  InitialValue="Please Select" Display="dynamic" Enabled="false"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                        </table>
                                    </asp:Panel>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right; white-space: nowrap; width: 30%" valign="top"><asp:Label ID="Label3" runat="server" Text="Future Development At This Location"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;</td>
                                <td style="text-align: left; white-space: nowrap; width: 25%" valign="top">
                                    <input type="checkbox" id="chk_FDATL" name="chk_FDATL" onclick="toggle(this,'therow03',['RequiredFieldValidator_FDATL_Specify'],['ddl_FDATL_Specify'] )" />
                                    <div id="therow03" style="display:none">
                                    <!--Future Development At This Location Panel -->
                                    <asp:Panel ID="Panel3" runat="server">
                                        <table cellpadding="5" cellspacing="0" border="0" bgcolor="#F0F0F0">
                                            <tr>
                                                <td style="width:30%; text-align:left; vertical-align:top"><asp:Label ID="Label8" runat="server" Text="Specify Future Land Use:"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /> </td>
                                                <td style="width:70%; text-align:left; vertical-align:top">
                                                    <asp:DropDownList ID="ddl_FDATL_Specify" runat="server" SelectedValue='<%# Bind("FDATL_Specify") %>' AutoPostBack="false" DataSourceID="ds_LU_FDATL" DataTextField="LU_CODE_Desc" DataValueField="LU_CODE_Desc">
        </asp:DropDownList>
       
        <asp:SqlDataSource ID="ds_LU_FDATL" runat="server" ConnectionString="<%$ ConnectionStrings:RLUISConnectionString %>"
            SelectCommand="SELECT [LU_CODE_Desc] FROM [RLUIS_LU]"></asp:SqlDataSource>
           
            &nbsp;<span style="color:Red">*</span>



  <asp:RequiredFieldValidator ID="RequiredFieldValidator_FDATL_Specify" runat="server" ErrorMessage="Please Select" ControlToValidate="ddl_FDATL_Specify"  InitialValue="Please Select" Display="dynamic" Enabled="false"></asp:RequiredFieldValidator>

                                                </td>
                                            </tr>  
                                        </table>
                                        <table cellpadding="5" cellspacing="0" border="0" width="100%" bgcolor="#F0F0F0">
                                            <tr>
                                                <td colspan="2" valign="top" align="left" style="width:100%"> &nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" style="width:100%; text-align:left; vertical-align:top">
                                                    <table cellpadding="0" cellspacing="0" border="0"  style="width:100%">
                                                        <tr>
                                                            <td style="width:15%; text-align:left; vertical-align:top"><asp:Label ID="Label11" runat="server" Text="Source"></asp:Label> </td>
                                                            <td style="width:85%; text-align:left; vertical-align:top">&nbsp;<asp:TextBox ID="FDATL_SourceTextBox" runat="server" onkeypress="return textboxMultilineMaxNumber(this,254)" Rows="4" Columns="41" TextMode="MultiLine" Text='<%# Bind("FDATL_Source") %>'></asp:TextBox>
                                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="FDATL_SourceTextBox"
                                                            Display="Dynamic" ErrorMessage="Please limit to 254 characters or less."
                                                            ValidationExpression="[\s\S]{1,255}"></asp:RegularExpressionValidator></td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table><br />
                                    </asp:Panel>
                                    </div>
                                </td>
                            </tr>  
                           
                            <!--Name and email textboxes -->
                            <tr>
                                <td style="width:30%; text-align:right; vertical-align:top; background-color:#FFFFFF  "><asp:Label ID="Label7" runat="server" Text="Comments & &nbsp;&nbsp;&nbsp;<br /> Additional Information:&nbsp;"></asp:Label>&nbsp;&nbsp;&nbsp;</td>
                                <td style="width:70%; text-align:left; vertical-align:top">
                                    <asp:TextBox ID="Comments" runat="server" TextMode="MultiLine" Width="55%" onkeypress="return textboxMultilineMaxNumber(this,254)" Columns="66" Rows="4" ToolTip="Please include any additional information (eg.g. name of development)" Text='<%# Bind("Comments") %>'> </asp:TextBox>
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Comments"
                    Display="Dynamic" ErrorMessage="Please limit to 254 characters or less."
                    ValidationExpression="[\s\S]{1,255}"></asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td style="width:30%; text-align:right; vertical-align:top; background-color:#FFFFFF  ">Your Name:<asp:Label ID="Label12" runat="server" AssociatedControlID="Name"></asp:Label>&nbsp;&nbsp;&nbsp; </td>
                                <td style="width:70%; text-align:left; vertical-align:top">
                                    <asp:TextBox ID="Name" Width="55%" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>&nbsp;<span style="color: red">&nbsp;*&nbsp;</span>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator_Name" runat="server" ControlToValidate="Name" Display="Dynamic" ErrorMessage="Name is required" EnableClientScript="true" SetFocusOnError="true"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td style="width:30%; text-align:right; vertical-align:top; background-color:#FFFFFF  "><asp:Label ID="Label13" runat="server" Text="Email:"  AssociatedControlID="Email"></asp:Label>&nbsp;&nbsp;&nbsp;</td>
                                <td style="width:70%; text-align:left; vertical-align:top">
                                    <asp:TextBox ID="Email" Width="55%" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>&nbsp;<span style="color: red">&nbsp;*&nbsp;</span>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator_Email" runat="server" ControlToValidate="Email" Display="Dynamic" ErrorMessage="Email is required" EnableClientScript="true" SetFocusOnError="true"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
                                        ControlToValidate="Email" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" Display="Dynamic" ErrorMessage="Please Enter a Valid e-mail"></asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td style="width:30%; text-align:left; vertical-align:top; background-color:#ffffff "> &nbsp;  </td>
                                <td style="width:70%; text-align:left; vertical-align:top"><br />
                                    <asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Submit"> </asp:Button>&nbsp;&nbsp;&nbsp;
                                    <asp:Button ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"> </asp:Button>
                                    <br /> <br />
                                </td>
                            </tr>
                        </table>
                    </InsertItemTemplate>
                </asp:FormView>
            </td>
        </tr>
    </table>      
   

 
     
       <asp:SqlDataSource ID="ds_RLUIS1" runat="server" ConnectionString="<%$ ConnectionStrings:RLUISConnectionString %>" OnInserted="SqlDataSource1_Inserted"
     
         
          InsertCommand="INSERT INTO [RLUIS] ([ParcelID], [ICLU_Correction], [ICLU_Specify], [IFLU_Specify], [FDATL_Specify], [FDATL_Source], [Comments], [Name], [Email]) VALUES (@ParcelID, @ICLU_Correction, @ICLU_Specify, @IFLU_Specify, @FDATL_Specify, @FDATL_Source, @Comments, @Name, @Email)"
         
          SelectCommand="SELECT [INPUTID], [ParcelID], [ICLU_Correction], [ICLU_Specify], [IFLU_Specify], [FDATL_Specify], [FDATL_Source], [Comments], [Name], [Email] FROM [RLUIS]"
         
          UpdateCommand="UPDATE [RLUIS] SET [ParcelID] = @ParcelID, [ICLU_Correction] = @ICLU_Correction, [ICLU_Specify] = @ICLU_Specify, [IFLU_Specify] = @IFLU_Specify, [FDATL_Specify] = @FDATL_Specify, [FDATL_Source] = @FDATL_Source, [Comments] = @Comments, [Name] = @Name, [Email] = @Email WHERE [INPUTID] = @INPUTID">
         
         
         
          <UpdateParameters>
              <asp:Parameter Name="ParcelID" Type="String" />
              <asp:Parameter Name="ICLU_Correction" Type="String" />
              <asp:Parameter Name="ICLU_Specify" Type="String" />
              <asp:Parameter Name="IFLU_Specify" Type="String" />
              <asp:Parameter Name="FDATL_Specify" Type="String" />
              <asp:Parameter Name="FDATL_Source" Type="String" />
              <asp:Parameter Name="Comments" Type="String" />
              <asp:Parameter Name="Name" Type="String" />
              <asp:Parameter Name="Email" Type="String" />
              <asp:Parameter Name="INPUTID" Type="Int16" />
          </UpdateParameters>
          <InsertParameters>
              <asp:Parameter Name="ParcelID" Type="String" />
              <asp:Parameter Name="ICLU_Correction" Type="String" />
              <asp:Parameter Name="ICLU_Specify" Type="String" />
              <asp:Parameter Name="IFLU_Specify" Type="String" />
              <asp:Parameter Name="FDATL_Specify" Type="String" />
              <asp:Parameter Name="FDATL_Source" Type="String" />
              <asp:Parameter Name="Comments" Type="String" />
              <asp:Parameter Name="Name" Type="String" />
              <asp:Parameter Name="Email" Type="String" />
          </InsertParameters>
      </asp:SqlDataSource>
     
      </div>
    </form>
</body>
</html>
---------

Thank you.      
     
     
0
 

Author Comment

by:Codeaddict7423
ID: 33566852
ramkisan,
In my default.aspx.cs file, i have the following code:

-----
protected void SqlDataSource1_Inserted(object sender, SqlDataSourceStatusEventArgs e)
    {
        if (e.Exception == null)
        {
            Response.Redirect("ThankYou.aspx");
        }
    }
------

perhaps this is where i insert the code you suggested...
0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points
ID: 33566859
In This case you can add First item as :
   <asp:DropDownList ID="ddl_ICLU_Specify" runat="server" SelectedValue='<%# Bind("ICLU_Specify") %>' AutoPostBack="false" DataSourceID="ds_LU_ICLU" DataTextField="LU_CODE_Desc" DataValueField="LU_CODE_Desc" AppendDataBoundItems="true" CausesValidation="true">  
<asp:ListItem value=" ">Please Select </asp:ListItem>
 </asp:DropDownList>


It will add first item as default and then It will append the valus from database
0
 

Author Comment

by:Codeaddict7423
ID: 33566963
ramkisan,
thank you. the code writes a " " to the database if the use does make a selection.
Thank you again.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now