You must Sign In to post a response.
  • Category: ASP.NET

    Checkbox values using c#.net

    hai i m hvin chkbox default i kept checked =false.
    if checked true ==i have sendt value L
    if checked false==i have sent value U..

    wn i m not clicking check box it going L value that is true
    dis my code
    if (chkLotbased.Checked = true)
    {
    chklot = "L";
    }
    else
    {
    chklot = "U";
    }
    objProcessMaster.LotBased = Convert.ToString(chklot.ToString());

    pls send me idea
    regards,
    vijay
  • #606704
    chkLotbased.Checked = true => assigning true to chkLotbased.Checked property
    chkLotbased.Checked == true => comparing if chkLotbased.Checked is true or not

    So, change your code to the following:


    if (chkLotbased.Checked == true)
    {
    chklot = "L";
    }


    Thanks & Regards
    Paritosh Mohapatra
    Microsoft MVP (ASP.Net/IIS)
    DotNetSpider MVM

  • #606710
    Please change the code to compare the value as below.


    if (chkLotbased.Checked == true)
    {
    chklot = "L";
    }
    else
    {
    chklot = "U";
    }
    objProcessMaster.LotBased = Convert.ToString(chklot.ToString());

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #606711
    Hi,
    The msitake in the code is in if block you have placed "=" which is an assignment operator. To compare you have to use the "==" operator.

    regards,
    Saru

  • #606734
    string ckklot="";
    if (chkLotbased.Checked == true)
    {
    chklot = "L";
    }
    else
    {
    chklot = "U";
    }

    it's proper work

  • #606740
    try this code

    string chklot="";
    if (chkLotbased.Checked)
    {
    chklot = "L";
    }
    else
    {
    chklot = "U";
    }


    hopw this will help you

  • #606787
    if (!chkLotbased.Checked)
    {
    chklot = "U";

    }
    else
    {
    chklot = "L";

    }
    objProcessMaster.LotBased = Convert.ToString(chklot.ToString());

  • #606838
    Try the below code:

    string chklot="";
    if (chkLotbased.Checked)
    {
    chklot = "L";
    }
    else
    {
    chklot = "U";
    }

    Regards,
    Sugandha
    Microsoft Certified Technology Specialist
    MY Blog..


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.