Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Checkbox with values

Reply
Thread Tools

Checkbox with values

 
 
=?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=
Guest
Posts: n/a
 
      10-05-2004
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
 
Reply With Quote
 
 
 
 
Martin Dechev
Guest
Posts: n/a
 
      10-05-2004
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" <Alessandro > wrote in
message news:6F26E5A6-D5AC-4286-A7FF-...
> 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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=
Guest
Posts: n/a
 
      10-05-2004
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" wrote:

> 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" <Alessandro > wrote in
> message news:6F26E5A6-D5AC-4286-A7FF-...
> > 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

>
>
>

 
Reply With Quote
 
Martin Dechev
Guest
Posts: n/a
 
      10-05-2004
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" <Alessandro > wrote in
message news:25E2F6E8-CD83-467A-9979-...
> 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" wrote:
>
> > 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" <Alessandro > wrote in
> > message news:6F26E5A6-D5AC-4286-A7FF-...
> > > 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

> >
> >
> >



 
Reply With Quote
 
Martin Dechev
Guest
Posts: n/a
 
      10-05-2004
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" <detcheff_@hotmail.com> wrote in message
news:#QkJr#...
> 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" <Alessandro > wrote in
> message news:25E2F6E8-CD83-467A-9979-...
> > 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" wrote:
> >
> > > 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" <Alessandro > wrote

in
> > > message news:6F26E5A6-D5AC-4286-A7FF-...
> > > > 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
> > >
> > >
> > >

>
>



 
Reply With Quote
 
=?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=
Guest
Posts: n/a
 
      10-05-2004
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" wrote:

> 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" <Alessandro > wrote in
> message news:25E2F6E8-CD83-467A-9979-...
> > 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" wrote:
> >
> > > 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" <Alessandro > wrote in
> > > message news:6F26E5A6-D5AC-4286-A7FF-...
> > > > 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
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=
Guest
Posts: n/a
 
      10-05-2004
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" wrote:

> 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" <detcheff_@hotmail.com> wrote in message
> news:#QkJr#...
> > 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" <Alessandro > wrote in
> > message news:25E2F6E8-CD83-467A-9979-...
> > > 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" wrote:
> > >
> > > > 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" <Alessandro > wrote

> in
> > > > message news:6F26E5A6-D5AC-4286-A7FF-...
> > > > > 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
> > > >
> > > >
> > > >

> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASPNET CheckBox and a CheckBox in a TemplateField Jason Huang ASP .Net 0 06-29-2007 12:35 AM
DataGrid and embeded Checkbox..How to find if checkbox clicked =?Utf-8?B?RG90TmV0RGV2?= ASP .Net 1 10-06-2006 04:11 PM
disable checkbox list checkbox Vikram ASP .Net 1 01-25-2006 02:59 PM
Howto bind CheckBox to the datagrid/ Then update the database field when the checkbox is clicked. Joey Pang ASP .Net Datagrid Control 4 06-13-2005 02:29 AM
Text on Checkbox below the checkbox tshad ASP .Net 0 04-14-2005 11:26 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57