Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. dynamic Checkbox issue

dynamic Checkbox issue

Scheduled Pinned Locked Moved ASP.NET
helpdesignsysadmin
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mobins
    wrote on last edited by
    #1

    i create dynamic checkboxes in coloum of table(<td id="trial" runat="server"></td>) from selecting quantity from dropdwonlist. well creating dynmic checkbox is not an issue.. well the issue is tht i am not able to check whether the Checkboxes is checked or not on a Button click.... the functiion used for generating dyamic checkbox.. protected void ddlList_SelectedIndexChanged(object sender, EventArgs e) { int no=convert.toint32(ddlist.selectedvalue); for(int i=1;i=<no;i++) { checkbox ch=new checkbox() ch.ID="chk_t"+i; ch.text="trl" trial.controls.add(ch); } } the function where i check whether checkboxes is checked protected void btnSave_Click(object sender, EventArgs e) { list<string> status_tn=new list<string>(); for (int j = 1; j <= no; j++) { trialid = "chk_t" + j; CheckBox checks=(CheckBox)trial.FindControl(trialid); if (checks.Checked) { status_tn.Add("Trial"); } } } in this function i get error : :System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object." Source="App_Web_pm_-zh7o" StackTrace: at btn_save_Click(Object sender, EventArgs e) in d:\Dot Net App\Talents\types_seeb.aspx.cs:line 325 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    S R R 3 Replies Last reply
    0
    • M mobins

      i create dynamic checkboxes in coloum of table(<td id="trial" runat="server"></td>) from selecting quantity from dropdwonlist. well creating dynmic checkbox is not an issue.. well the issue is tht i am not able to check whether the Checkboxes is checked or not on a Button click.... the functiion used for generating dyamic checkbox.. protected void ddlList_SelectedIndexChanged(object sender, EventArgs e) { int no=convert.toint32(ddlist.selectedvalue); for(int i=1;i=<no;i++) { checkbox ch=new checkbox() ch.ID="chk_t"+i; ch.text="trl" trial.controls.add(ch); } } the function where i check whether checkboxes is checked protected void btnSave_Click(object sender, EventArgs e) { list<string> status_tn=new list<string>(); for (int j = 1; j <= no; j++) { trialid = "chk_t" + j; CheckBox checks=(CheckBox)trial.FindControl(trialid); if (checks.Checked) { status_tn.Add("Trial"); } } } in this function i get error : :System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object." Source="App_Web_pm_-zh7o" StackTrace: at btn_save_Click(Object sender, EventArgs e) in d:\Dot Net App\Talents\types_seeb.aspx.cs:line 325 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

      S Offline
      S Offline
      Satish_S
      wrote on last edited by
      #2

      i realize when page get posts check box not generating dynamically so try to re generate the dynamic check boxes in your save click, sorry if i am wrong

      protected void btnSave_Click(object sender, EventArgs e)
      {

      ddlList_SelectedIndexChanged(sender,e)

      /*your save functionality*/

      }

      1 Reply Last reply
      0
      • M mobins

        i create dynamic checkboxes in coloum of table(<td id="trial" runat="server"></td>) from selecting quantity from dropdwonlist. well creating dynmic checkbox is not an issue.. well the issue is tht i am not able to check whether the Checkboxes is checked or not on a Button click.... the functiion used for generating dyamic checkbox.. protected void ddlList_SelectedIndexChanged(object sender, EventArgs e) { int no=convert.toint32(ddlist.selectedvalue); for(int i=1;i=<no;i++) { checkbox ch=new checkbox() ch.ID="chk_t"+i; ch.text="trl" trial.controls.add(ch); } } the function where i check whether checkboxes is checked protected void btnSave_Click(object sender, EventArgs e) { list<string> status_tn=new list<string>(); for (int j = 1; j <= no; j++) { trialid = "chk_t" + j; CheckBox checks=(CheckBox)trial.FindControl(trialid); if (checks.Checked) { status_tn.Add("Trial"); } } } in this function i get error : :System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object." Source="App_Web_pm_-zh7o" StackTrace: at btn_save_Click(Object sender, EventArgs e) in d:\Dot Net App\Talents\types_seeb.aspx.cs:line 325 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

        R Offline
        R Offline
        raju melveetilpurayil
        wrote on last edited by
        #3

        mobins wrote:

        CheckBox checks=(CheckBox)trial.FindControl(trialid); if (checks.Checked) { status_tn.Add("Trial"); }

        //to solve error

        CheckBox checks=(CheckBox)trial.FindControl(trialid);
        if(checks!=null)
        {
        if (checks.Checked)
        {
        status_tn.Add("Trial");
        }
        }

        1 Reply Last reply
        0
        • M mobins

          i create dynamic checkboxes in coloum of table(<td id="trial" runat="server"></td>) from selecting quantity from dropdwonlist. well creating dynmic checkbox is not an issue.. well the issue is tht i am not able to check whether the Checkboxes is checked or not on a Button click.... the functiion used for generating dyamic checkbox.. protected void ddlList_SelectedIndexChanged(object sender, EventArgs e) { int no=convert.toint32(ddlist.selectedvalue); for(int i=1;i=<no;i++) { checkbox ch=new checkbox() ch.ID="chk_t"+i; ch.text="trl" trial.controls.add(ch); } } the function where i check whether checkboxes is checked protected void btnSave_Click(object sender, EventArgs e) { list<string> status_tn=new list<string>(); for (int j = 1; j <= no; j++) { trialid = "chk_t" + j; CheckBox checks=(CheckBox)trial.FindControl(trialid); if (checks.Checked) { status_tn.Add("Trial"); } } } in this function i get error : :System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object." Source="App_Web_pm_-zh7o" StackTrace: at btn_save_Click(Object sender, EventArgs e) in d:\Dot Net App\Talents\types_seeb.aspx.cs:line 325 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

          R Offline
          R Offline
          Rajendra Prasad Panchati
          wrote on last edited by
          #4

          Hi, Before Checking the status of check boxes whether they are checked or not, Please Confirm that control is exists or not. And also confirm that the dynamical checkboxes generation code is not executed on button click event. I hope u understand it :thumbsup:...

          Rajendra Prasad Panchati .Net/Sharepoint Software Enginner hyderabad.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups