使用单选按钮在gridview中添加日期 [英] add days in date in gridview using radio buttons
本文介绍了使用单选按钮在gridview中添加日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有3个单选按钮,我想在日期中添加30或60或90天。
这是我的代码。
I have 3 radio buttons and i want to add 30 or 60 or 90 days to the date.
This is my code.
protected void gvImages_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\site\SamsungClassifieds\App_Data\Dorknozzle.mdf;Integrated Security=True;User Instance=True");
con.Open();
//DateTime date = DateTime.Now;
//date = date.AddDays(30);
//int userid = Convert.ToInt32(gvImages.DataKeys[e.RowIndex].Values["lbladid"].ToString());
Label lbladid = (Label)gvImages.Rows[e.RowIndex].FindControl("lbladid");
TextBox txttitle = (TextBox)gvImages.Rows[e.RowIndex].FindControl("txttitle");
TextBox txtdesc = (TextBox)gvImages.Rows[e.RowIndex].FindControl("txtdesc");
Label lblprice = (Label)gvImages.Rows[e.RowIndex].FindControl("lblprice");
TextBox txtprice = (TextBox)gvImages.Rows[e.RowIndex].FindControl("txtprice");
RadioButton rd1 = (RadioButton)gvImages.Rows[e.RowIndex].FindControl("rb30");
RadioButton rd2 = (RadioButton)gvImages.Rows[e.RowIndex].FindControl("rb60");
RadioButton rd3 = (RadioButton)gvImages.Rows[e.RowIndex].FindControl("rb90");
SqlCommand cmd = new SqlCommand("UPDATE AD_DETAIL SET AD_TITLE ='" + txttitle.Text + "',AD_DESC ='" + txtdesc.Text + "',AD_PRICE ='" + txtprice.Text + "'WHERE AD_ID = '" + lbladid.Text + "'", con);
cmd.ExecuteNonQuery();
gvImages.EditIndex = -1;
Binddata();
con.Close();
}
推荐答案
daterequired = DateAdd(DateInterval.Day,30,Now.Date )...根据需要用60或90替换30。
daterequired = DateAdd(DateInterval.Day, 30, Now.Date)... replace 30 with 60 or 90 as required.
这篇关于使用单选按钮在gridview中添加日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文