Jump to content

Eu queria ler e guardar os dados da checkbox.


Recommended Posts

Posted (edited)

Eu queria ler e guardar os dados da checkbox.

Na tabela de sql aparece 1 ou 0, 1 significa que a checkbox tá seleccionada e 0 não está

  protected void btnSelecionarType_Click(object sender, EventArgs e)
	{
		foreach (GridViewRow row in gdvEntryTypes.Rows)
		{
			CheckBox ch = (CheckBox)row.FindControl("CheckBox2");
			if (ch != null)
			{
				if (ch.Checked)
				{

					txtTypeId.Text = row.Cells[1].Text;
					txtLancamento.Text = row.Cells[2].Text;
					txtDescricao.Text = row.Cells[3].Text;
					chkSistema ?       =row.Cells[4]. ?
					chkFiscal ?           =row.Cells[5]?

				}

			}
		}

como é que eu faço para ler os dados da checkbox ??? e para guardar ???

Edited by jrlcp32
Posted

Você pode usar propriedade IsChecked

chkSistema.IsChecked = Convert.ToBoolean(row.Cells[4].Value);

para fazer o inverso, você pode usar o Convert.ToInt32, assim

var valorInt=Convert.ToInt32(chkSistema.IsChecked.GetValueOrDefault());

Fernando Lage Bastos - MCP/MCTS/MCPD

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.