TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sarbjeet singh
NA
29
0
inserting data into database after selected indexchanged in dropdownlist
Mar 5 2011 1:22 AM
hi Guys ,Plz help me out
i m havin the following code
<body>
<form id="form1" runat="server">
<div>
<div>
Have Pan Card:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="316px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>-----select----- </asp:ListItem>
<asp:ListItem>yes</asp:ListItem>
<asp:ListItem>no</asp:ListItem>
</asp:DropDownList><br />
</div>
<div id="div1" runat="server">Enter Ist Choice
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </div>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</form>
</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
Reply
Answers (
9
)
ASP.NET membership provider export and import
Compare the data of one excel file with another excel file?