<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="316px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</body>
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 that
Parameter @pan has no default value
plz help its urgent