Checkbox with values

Discussion in 'ASP .Net' started by =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=, Oct 5, 2004.

  1. 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
     
    =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=, Oct 5, 2004
    #1
    1. Advertising

  2. 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:...
    > 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
     
    Martin Dechev, Oct 5, 2004
    #2
    1. Advertising

  3. 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:...
    > > 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

    >
    >
    >
     
    =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=, Oct 5, 2004
    #3
  4. 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:...
    > 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:...
    > > > 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

    > >
    > >
    > >
     
    Martin Dechev, Oct 5, 2004
    #4
  5. 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" <> 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:...
    > > 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:...
    > > > > 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
    > > >
    > > >
    > > >

    >
    >
     
    Martin Dechev, Oct 5, 2004
    #5
  6. 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:...
    > > 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:...
    > > > > 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
    > > >
    > > >
    > > >

    >
    >
    >
     
    =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=, Oct 5, 2004
    #6
  7. 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" <> 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:...
    > > > 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:...
    > > > > > 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
    > > > >
    > > > >
    > > > >

    > >
    > >

    >
    >
    >
     
    =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=, Oct 5, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    0
    Views:
    577
    tshad
    Apr 15, 2005
  2. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,429
    ThunderMusic
    Jan 25, 2006
  3. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    864
    David Wier
    Oct 6, 2006
  4. Jason Huang
    Replies:
    0
    Views:
    584
    Jason Huang
    Jun 29, 2007
  5. Joey Pang
    Replies:
    4
    Views:
    563
    Joey Pang
    Jun 13, 2005
Loading...

Share This Page