Click here to Skip to main content
13,048,584 members (90,934 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have a 3-tier architecture...trying to insert something with checkboxlist...

would this bit of code even work? every time i try to insert...i get a fail.

    protected void submitButton_Click(object sender, EventArgs e)
        //Lets validate the page first
        if (!Page.IsValid)
        int intResult = 0;
        // Page is valid, lets go ahead and insert records
        // Instantiate BAL object
        sBLL scBLL = new sBLL();
        // Instantiate the object we have to deal with
        sBO scBO = new sBO();
        // set the properties of the object
        sDAL scdal = new sDAL();
        scBO.scholarshipName = scNameText.Text;
        scBO.orgID = 1;
            intResult = scBLL.Insert(scBO);
            if (intResult > 0)
                lblMessage.Text = "New record inserted successfully.";
                lblMessage.Text = "failed";
        catch (Exception ee)
            lblMessage.Text = ee.Message.ToString();
            int sID = scBO.sID;
            foreach (ListItem li in CheckBoxList1.Items)
                if (li.Selected)
                    mascidBLL masciBLL = new mascidBLL();
                    mascidBO masciBO = new mascidBO();
                    masciBO.sID = sID;
                    masciBO.majorID = int.Parse(li.Value);

            scBO = null;
            scBLL = null;

i have a bll, bo and a dal if that helps.

thanks in advance
Posted 8-May-13 14:52pm
Updated 8-May-13 18:08pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You never added or inserted anything. Take a look: all controls have some parent. To insert anything, you should first create a new object. This means a call to one (exactly one) constructor. Next step, you need to establish a parent-child relation between parent and a new element. So, you need one constructor call and one Insert/Add call.

As you though you were close, I trust I can leave the rest to you. Especially in case you did not really tell us an exact type of the ListItem or CheckBoxList classes. Did you know that there are more then one UI library in .NET. Even though I can guess what is it, I think guesswork is not an appropriate thing to do here. You ask a question, you specify all which is relevant to you question, OK? In particular, you should tag UI library or application type.

Now, let's see if you can complete the solution of the problem.

Well, also, it's not clear why do you call it "batch" and how it this related to "update" (of what). If you have some follow-up questions, I hope you explain everything the way leaving no ambiguity.

Good luck,
Member 9339684 9-May-13 0:03am
honestly, you couldn't have been anymore unhelpful or rude.

yesterday i asked a question and posted all the code i could and got complaints about posting "TOO MUCH CODE" some of you prima donnas need to chill. i said THINK i'm close. if you simply asked for more code, i'd have happily provided it.
Too bad, for you. You are not collaborative. No more help, sorry.
Member 9339684 9-May-13 1:14am
you weren't any help so it's really no loss. please stay out of this wuestion if you're going to be a jerk.

THAT is how you could be helpful.
As to "stay out", sorry, no way. I'll have to consider your behavior as unacceptable, to make you a candidate for cancellation of your account. These comments are a bit too much. We don't tolerate rude/offensive behavior.
Member 9339684 9-May-13 1:22am
rude offensive behavior? check your posts
i'm trying to ask a question adn get some help and you came onto my question acting like a complete dbag and then proceeded to block my question from being answered.

just because you think you know some code doesnt give you the right to act like a jerk to new coders trying to get some help. you could have asked for more code to see the problem. instead you acted like a jerk.
Thank you, case closed...
Member 9339684 9-May-13 1:33am
you have some serious issues. everyone has to learn somehow, everyone makes mistakes asking questions. feel free to "answer" other questions and leave this one alone.

a message has already been sent to the webmaster in regards to your dickish behavior

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100