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
madhu goud
NA
36
14.2k
How to update text box value when the date is changed
Oct 14 2015 4:57 AM
I have a registration page
NoOfmonths(drop down list values are 2 3 4....)
StartDate
End Date(automatically comes based on selection of above no of months if number of months 3 then end date=startdate+3 months)
Payment is 5000
i have saved these details in database and binded to grid view
whenever the start date is crossed one month i want to update payment value to double
like that i want to update payment for 3 months(example for 3 months 5000+5000+5000=15000 )
this is my code
SqlConnection con = new SqlConnection(@"server=SYS8\SQLSERVER2008DE;database=Naresh;Integrated Security=true");
protected void Page_Load(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("select * from ValueUpdate", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void txtStartDate_TextChanged(object sender, EventArgs e)
{
string inputString = txtStartDate.Text;
DateTime dt = DateTime.ParseExact(inputString, "MM/dd/yyyy", CultureInfo.InvariantCulture);
dt = dt.AddMonths(Convert.ToInt32(ddlmonths.SelectedItem.ToString()));
txtEndDate.Text = dt.ToString("MM/dd/yyyy");
}
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("Insert into ValueUpdate (NoOfMonths,StartDate,EndDate,Payment) values('" + ddlmonths.SelectedItem + "','" + txtStartDate.Text + "','" + txtEndDate.Text + "','" + txtMonthlyPay.Text + "')", con);
cmd.ExecuteNonQuery();
Reply
Answers (
2
)
Browser's back button causes double entries on database.
Angular Js