Checkbox with values

G

Guest

Hi,
I have to create a CheckBox, and i would like will be checked if there is a
value in a property added, and not checked if there is another value.

I added 2 property (string) to the checkbox; the first , CheckedValue is the
value for whom i want the check will be checked. The second is the opposite.
I Added a handler to the checkbox in this way:

this.DataBinding+=new EventHandler(AreaITWebCheckBox_DataBinding);

and

private void AreaITWebCheckBox_DataBinding(object sender, EventArgs e)
{
}

I binded another new property (Valore) in this way:

DataBinder.Eval(dsGestione1, "Tables[RUOLO].DefaultView.[0].IND_ADM")
where IND_ADM can have value "S" or "N".

The question is:
How can i acced to the value of property Valore from the eventHandler?
If this is not possible, how can I realize this component in another way?

Sincerely
Alessandro
 
M

Martin Dechev

Hi, Alessandro,

Try it this way:

public override bool Checked
{
get
{
object o = ViewState["Checked"];
if(o != null)
return (bool)o;
return false;
}
set
{
ViewState["Checked"] = value;
}
}

public string Scelto
{
get
{
return (Checked ? "S" : "N");
}
set
{
Checked = (value == "S");
}
}

Hope this helps
Martin
 
G

Guest

Hi,
I appreciated your help, but my problem, I think, is quite different.
I have to read the values to decode the (checked or not) status from a
datacolumn of a datatable binded to a checkbox's property. Is there a way to
acceed to this data in some events of checkbox?
I wouldn't like to use the viewstate...
Thank you
Alessandro

Martin Dechev said:
Hi, Alessandro,

Try it this way:

public override bool Checked
{
get
{
object o = ViewState["Checked"];
if(o != null)
return (bool)o;
return false;
}
set
{
ViewState["Checked"] = value;
}
}

public string Scelto
{
get
{
return (Checked ? "S" : "N");
}
set
{
Checked = (value == "S");
}
}

Hope this helps
Martin
Alessandro Rossi said:
Hi,
I have to create a CheckBox, and i would like will be checked if there is a
value in a property added, and not checked if there is another value.

I added 2 property (string) to the checkbox; the first , CheckedValue is the
value for whom i want the check will be checked. The second is the opposite.
I Added a handler to the checkbox in this way:

this.DataBinding+=new EventHandler(AreaITWebCheckBox_DataBinding);

and

private void AreaITWebCheckBox_DataBinding(object sender, EventArgs e)
{
}

I binded another new property (Valore) in this way:

DataBinder.Eval(dsGestione1, "Tables[RUOLO].DefaultView.[0].IND_ADM")
where IND_ADM can have value "S" or "N".

The question is:
How can i acced to the value of property Valore from the eventHandler?
If this is not possible, how can I realize this component in another way?

Sincerely
Alessandro
 
M

Martin Dechev

Hi,

How about in a DataGrid:

<asp:templatecolumn headertext="Conferma"><itemtemplate>
<custom:checkbox id="customCheckBox1" runat="server"
Scelto='<%#DataBinder.Eval(Container.DataItem, "CONFERMATO")%>'/>
</itemtemplate></asp:templatecolumn>

Greetings
Martin
Alessandro Rossi said:
Hi,
I appreciated your help, but my problem, I think, is quite different.
I have to read the values to decode the (checked or not) status from a
datacolumn of a datatable binded to a checkbox's property. Is there a way to
acceed to this data in some events of checkbox?
I wouldn't like to use the viewstate...
Thank you
Alessandro

Martin Dechev said:
Hi, Alessandro,

Try it this way:

public override bool Checked
{
get
{
object o = ViewState["Checked"];
if(o != null)
return (bool)o;
return false;
}
set
{
ViewState["Checked"] = value;
}
}

public string Scelto
{
get
{
return (Checked ? "S" : "N");
}
set
{
Checked = (value == "S");
}
}

Hope this helps
Martin
Alessandro Rossi said:
Hi,
I have to create a CheckBox, and i would like will be checked if there
is
a
value in a property added, and not checked if there is another value.

I added 2 property (string) to the checkbox; the first , CheckedValue
is
the
value for whom i want the check will be checked. The second is the opposite.
I Added a handler to the checkbox in this way:

this.DataBinding+=new EventHandler(AreaITWebCheckBox_DataBinding);

and

private void AreaITWebCheckBox_DataBinding(object sender, EventArgs e)
{
}

I binded another new property (Valore) in this way:

DataBinder.Eval(dsGestione1, "Tables[RUOLO].DefaultView.[0].IND_ADM")
where IND_ADM can have value "S" or "N".

The question is:
How can i acced to the value of property Valore from the eventHandler?
If this is not possible, how can I realize this component in another way?

Sincerely
Alessandro
 
M

Martin Dechev

Hi,

I'm sorry for misleading you. For binding you will have to do something like
this:

<custom:checkbox id="customCheckBox1" runat="server"
checked='<%#((DataBinder.Eval(Container.DataItem, "CONFERMATO") as string)
== "S")%>'/>

Greetings
Martin
Martin Dechev said:
Hi,

How about in a DataGrid:

<asp:templatecolumn headertext="Conferma"><itemtemplate>
<custom:checkbox id="customCheckBox1" runat="server"
Scelto='<%#DataBinder.Eval(Container.DataItem, "CONFERMATO")%>'/>
</itemtemplate></asp:templatecolumn>

Greetings
Martin
Alessandro Rossi said:
Hi,
I appreciated your help, but my problem, I think, is quite different.
I have to read the values to decode the (checked or not) status from a
datacolumn of a datatable binded to a checkbox's property. Is there a
way
to
acceed to this data in some events of checkbox?
I wouldn't like to use the viewstate...
Thank you
Alessandro

Martin Dechev said:
Hi, Alessandro,

Try it this way:

public override bool Checked
{
get
{
object o = ViewState["Checked"];
if(o != null)
return (bool)o;
return false;
}
set
{
ViewState["Checked"] = value;
}
}

public string Scelto
{
get
{
return (Checked ? "S" : "N");
}
set
{
Checked = (value == "S");
}
}

Hope this helps
Martin
message Hi,
I have to create a CheckBox, and i would like will be checked if
there
CheckedValue
is
the
value for whom i want the check will be checked. The second is the
opposite.
I Added a handler to the checkbox in this way:

this.DataBinding+=new EventHandler(AreaITWebCheckBox_DataBinding);

and

private void AreaITWebCheckBox_DataBinding(object sender, EventArgs e)
{
}

I binded another new property (Valore) in this way:

DataBinder.Eval(dsGestione1, "Tables[RUOLO].DefaultView.[0].IND_ADM")
where IND_ADM can have value "S" or "N".

The question is:
How can i acced to the value of property Valore from the eventHandler?
If this is not possible, how can I realize this component in another way?

Sincerely
Alessandro
 
G

Guest

Excuse me,
you know if is possible to write an instruction like:
Scelto='<%#(DataBinder.Eval(Container.DataItem,
"CONFERMATO")==AnotherProperty)%>'/>

so I have true if is equal and false if not?

Thank you
Alessandro.


Martin Dechev said:
Hi,

How about in a DataGrid:

<asp:templatecolumn headertext="Conferma"><itemtemplate>
<custom:checkbox id="customCheckBox1" runat="server"
Scelto='<%#DataBinder.Eval(Container.DataItem, "CONFERMATO")%>'/>
</itemtemplate></asp:templatecolumn>

Greetings
Martin
Alessandro Rossi said:
Hi,
I appreciated your help, but my problem, I think, is quite different.
I have to read the values to decode the (checked or not) status from a
datacolumn of a datatable binded to a checkbox's property. Is there a way to
acceed to this data in some events of checkbox?
I wouldn't like to use the viewstate...
Thank you
Alessandro

Martin Dechev said:
Hi, Alessandro,

Try it this way:

public override bool Checked
{
get
{
object o = ViewState["Checked"];
if(o != null)
return (bool)o;
return false;
}
set
{
ViewState["Checked"] = value;
}
}

public string Scelto
{
get
{
return (Checked ? "S" : "N");
}
set
{
Checked = (value == "S");
}
}

Hope this helps
Martin
message Hi,
I have to create a CheckBox, and i would like will be checked if there is
a
value in a property added, and not checked if there is another value.

I added 2 property (string) to the checkbox; the first , CheckedValue is
the
value for whom i want the check will be checked. The second is the
opposite.
I Added a handler to the checkbox in this way:

this.DataBinding+=new EventHandler(AreaITWebCheckBox_DataBinding);

and

private void AreaITWebCheckBox_DataBinding(object sender, EventArgs e)
{
}

I binded another new property (Valore) in this way:

DataBinder.Eval(dsGestione1, "Tables[RUOLO].DefaultView.[0].IND_ADM")
where IND_ADM can have value "S" or "N".

The question is:
How can i acced to the value of property Valore from the eventHandler?
If this is not possible, how can I realize this component in another way?

Sincerely
Alessandro
 
G

Guest

but if I would like to substitute the "S" with a property of a checkbox, you
know if it is possible?, and how?
<custom:checkbox id="customCheckBox1" runat="server"
checked='<%#((DataBinder.Eval(Container.DataItem, "CONFERMATO") as string)
== Property)%>'/>

Thank you
Alessandro

Martin Dechev said:
Hi,

I'm sorry for misleading you. For binding you will have to do something like
this:

<custom:checkbox id="customCheckBox1" runat="server"
checked='<%#((DataBinder.Eval(Container.DataItem, "CONFERMATO") as string)
== "S")%>'/>

Greetings
Martin
Martin Dechev said:
Hi,

How about in a DataGrid:

<asp:templatecolumn headertext="Conferma"><itemtemplate>
<custom:checkbox id="customCheckBox1" runat="server"
Scelto='<%#DataBinder.Eval(Container.DataItem, "CONFERMATO")%>'/>
</itemtemplate></asp:templatecolumn>

Greetings
Martin
Alessandro Rossi said:
Hi,
I appreciated your help, but my problem, I think, is quite different.
I have to read the values to decode the (checked or not) status from a
datacolumn of a datatable binded to a checkbox's property. Is there a
way
to
acceed to this data in some events of checkbox?
I wouldn't like to use the viewstate...
Thank you
Alessandro

:

Hi, Alessandro,

Try it this way:

public override bool Checked
{
get
{
object o = ViewState["Checked"];
if(o != null)
return (bool)o;
return false;
}
set
{
ViewState["Checked"] = value;
}
}

public string Scelto
{
get
{
return (Checked ? "S" : "N");
}
set
{
Checked = (value == "S");
}
}

Hope this helps
Martin
message Hi,
I have to create a CheckBox, and i would like will be checked if
there
is
a
value in a property added, and not checked if there is another value.

I added 2 property (string) to the checkbox; the first ,
CheckedValue
is
the
value for whom i want the check will be checked. The second is the
opposite.
I Added a handler to the checkbox in this way:

this.DataBinding+=new EventHandler(AreaITWebCheckBox_DataBinding);

and

private void AreaITWebCheckBox_DataBinding(object sender, EventArgs e)
{
}

I binded another new property (Valore) in this way:

DataBinder.Eval(dsGestione1, "Tables[RUOLO].DefaultView.[0].IND_ADM")
where IND_ADM can have value "S" or "N".

The question is:
How can i acced to the value of property Valore from the eventHandler?
If this is not possible, how can I realize this component in another way?

Sincerely
Alessandro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top