?
Solved

required field validator for databound dropdownlist

Posted on 2010-08-30
10
Medium Priority
?
1,707 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

 
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
 
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 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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