0

So I have an event that is when you click a button I want to send an int, string, datetime and bool to my database. Right now it will get the input from my webform for the "Company" and the "DayNumber". I want to get the value of my CheckBox01 as the boolean for WeatherRain and the input from the Date. You should be able to choose the date not just take it from "now". I don't know what would be the best way to get this done, I do have around 100 different fields to get user input from.

protected void btnTryck_Click(object sender, EventArgs e)
{
    Dagbok bok = DagbokFactory.CreateNew();

    bok.Company = String.Format(TextBox1.Text);
    bok.DayNumber = Convert.ToInt32(TextBox19.Text);
    bok.WeatherRain = false;
    bok.Date = DateTime.Now;
}
2
  • Do you have 100 input field on your page?? Commented Mar 25, 2013 at 10:59
  • Yes unfortunately I do have 100 input fields, it is a client that want their "daily diary" for building contractors as a web form instead of in paper form. It will be horrible to work with since over 50 of them are mandatory. Commented Mar 25, 2013 at 11:07

2 Answers 2

1

In order to get the boolean from your CheckBox01 use its Checked property.

bok.WeatherRain = CheckBox01.Checked;

As for the date problem, I'd suggest using a DateTimePicker control to let the user select the date and get its value with the Value property.

Sign up to request clarification or add additional context in comments.

Comments

1

Use Checkbox's checked property for this as shown below:

protected void btnTryck_Click(object sender, EventArgs e)
{
    Dagbok bok = DagbokFactory.CreateNew();

    bok.Company = String.Format(TextBox1.Text);
    bok.DayNumber = Convert.ToInt32(TextBox19.Text);
    bok.WeatherRain = CheckBox01.Checked;
    bok.Date = DateTime.Now;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.