i m havin the following code
Have Pan Card:
Enter Ist Choice
and the code behind is here
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class demo : System.Web.UI.Page
{
string pan, panno;
OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["adbudhconnection"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
div1.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
OleDbCommand cmd = new OleDbCommand("insert into demo(pan,panno)values(@pan,@panno)", con);
cmd.Parameters.AddWithValue("@pan", pan);
cmd.Parameters.AddWithValue("@panno", panno);
cmd.ExecuteNonQuery();
con.Close();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedItem.Text == "yes")
{
div1.Visible = true;
pan = DropDownList1.SelectedItem.Text;
panno = TextBox1.Text;
}
else if (DropDownList1.SelectedItem.Text == "no")
{
pan = DropDownList1.SelectedItem.Text;
panno = "n/a";
}
}
}
this gives the error thatParameter @pan has no default value
plz help its urgent

Suthish NairRank #92 · 22.8K reputationPosted Mar 4, 2011, 8:29 PM EST
sarbjeet singh69 reputationPosted Mar 4, 2011, 8:54 PM EST
could u plz help me out
Krishna GaradRank #191 · 12.8K reputationPosted Mar 4, 2011, 9:24 PM EST
Page_load
{
if(!IsPostBack)
{
div1.visible=false;
}
}
the value is empty because when you fire any other event then first page_load event fires again which set the values default to control.
sarbjeet singh69 reputationPosted Mar 4, 2011, 9:39 PM EST
Krishna GaradRank #191 · 12.8K reputationPosted Mar 4, 2011, 9:45 PM EST
pan = DropDownList1.SelectedItem.Text.ToString();
sarbjeet singh69 reputationPosted Mar 4, 2011, 10:51 PM EST
and i have declared
static string pan,panno;
Krishna GaradRank #191 · 12.8K reputationPosted Mar 4, 2011, 11:22 PM EST
Classname.panno
or replace following line
cmd.Parameters.AddWithValue("@panno",TexBbox1.Text);
Suthish NairRank #92 · 22.8K reputationPosted Mar 5, 2011, 2:00 AM EST
cmd.Parameters.AddWithValue("@pan", DropDownList1.SelectedItem.Text);
cmd.Parameters.AddWithValue("@panno", (DropDownList1.SelectedItem.Text == "no" ? "n/a" :
TextBox1.Text));
DropDownList1_SelectedIndexChanged
if (DropDownList1.SelectedItem.Text == "yes")
}
if(!IsPostBack) { } check
Suthish NairRank #92 · 22.8K reputationPosted Mar 7, 2011, 9:28 AM EST