Solved

asp.net database populated drop down list

Posted on 2009-05-07
2
455 Views
Last Modified: 2012-05-06
I have a page where i'm populating a dropdown list from a database.  Right now the code behind file only reads the form values and then changes a label to show those values.  The label is not getting changed and the page acts differently in firefox 3 and internet explorer 7.  In firefox, the page just doesn't do anything, in IE7 i get the following error message:

/*****
Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
*****/

I don't understand why this is not working, I simply want to read the 4 form values and insert them into a database but I like to check as I go and it's not even working right now.
page.aspx
//////////////////////////
 
			<div class="post">
			<div class="post-bgtop">
			<div class="post-bgbtm">
				<h1 class="title"><a href="#">Biker Registration  </a></h1>					
                <asp:Label ID="lblInsSuccess" runat="server" Text="here" CssClass="redtext"></asp:Label>
				<div class="entry">
				<form method="post" id="BikReg">
				<p>
				<label class="reglabel">&nbsp;</label>&nbsp;
				*If you don&#39;t see your company listed here, you will need to register above.
				</p>
                    <asp:SqlDataSource ID="srcBus" runat="server"
                    ProviderName="System.Data.SqlClient"
                    connectionString="<%$ connectionStrings:LOCcbc %>"
                    SelectCommand="Select BUSINESS_ID, BUSINESS_NAME FROM BUSINESS ORDER BY BUSINESS_NAME ASC"                    
                    />
				<p>
				    <label for="indBusID" class="reglabel">Your Employer: &nbsp;</label>
                    <asp:DropDownList ID="indBusID" runat="server" AutoPostBack="true" 
                    DataSourceID="srcBus" DataTextField="BUSINESS_NAME" DataValueField="BUSINESS_ID" />
                </p>
				<p>
				    <label for="indTxtFName" class="reglabel">First Name: &nbsp;</label>
                    <asp:TextBox ID="indTxtFName" runat="server" CssClass="reginput"></asp:TextBox>
                </p>
				<p>
				    <label for="indTxtLName" class="reglabel">Last Name: &nbsp;</label>
                    <asp:TextBox ID="indTxtLName" runat="server" CssClass="reginput"></asp:TextBox>
                </p>
				<p>
				    <label for="indTxtEmail" class="reglabel">Email Address: &nbsp;</label>
                    <asp:TextBox ID="indTxtEmail" runat="server" CssClass="reginput"></asp:TextBox>
                </p>
				<p><label for="indRegSubmit" class="reglabel"> &nbsp; </label>
                <asp:Button ID="indRegSubmit" runat="server" Text="Submit" onclick="indRegSubmit_Click" /></p>
                </form>
				</div>
			</div>
			</div>
			</div>
 
////////////////////////////////////
 
codebehind file
 
///////////////////////////////////
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
 
public partial class register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    public static string FixQuotes(string strValue)
    {
        return strValue.Replace("'", "''");
    }
 
    protected void indRegSubmit_Click(object sender, EventArgs e)
    {
        string sqlInsertInd;
        string sqlInsLog1;
        string sqlInsLog2;
        string sqlInsLog3;
        string sqlInsLog4;
        string sqlInsLog5;
        string sqlInsLog6;
        string sqlInsLog7;
 
        int frmBusID = Convert.ToInt32(indBusID.SelectedItem.Value);
        string frmFName = indTxtFName.Text;
        string frmLName = indTxtLName.Text;
        string frmEmail = indTxtEmail.Text;
 
        lblInsSuccess.Text = "businessid: " + frmBusID;
        lblInsSuccess.Text += "<br />frmFName: " + frmFName;
        lblInsSuccess.Text += "<br />frmLName: " + frmLName;
        lblInsSuccess.Text += "<br />frmEmail: " + frmEmail;
        }
}

Open in new window

0
Comment
Question by:rondre
[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
2 Comments
 
LVL 18

Accepted Solution

by:
David Robitaille earned 500 total points
ID: 24329134
it<s because you have html tags within the content of your form (the data).

First, you could try to remove the "<br />"
 
0
 

Author Closing Comment

by:rondre
ID: 31579092
Thanks davrob60 - me being an idiot and not mentioning other parts of the site, I'm using master pages and the form tag was already in the masterpage file w/ runat=server.  I removed the form tag from this and it works perfect.  Thanks for the info!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Setting up a IIS 8 Web Server to send and receive XML files 7 100
ASP.NET MVC - Views 3 42
disadvantage of code behind appoarch in asp.net 3 29
aspx ascx, c# 7 18
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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