Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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)
            return;
 
        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;
        
 
        try
        {
            intResult = scBLL.Insert(scBO);
            if (intResult > 0)
                lblMessage.Text = "New record inserted successfully.";
            else
                lblMessage.Text = "failed";
 
        }
        catch (Exception ee)
        {
            lblMessage.Text = ee.Message.ToString();
        }
        finally
        {
            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 15:52pm
Edited 8-May-13 19:08pm
v2

1 solution

Rate this: bad
good
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,
—SA
  Permalink  
Comments
Member 9339684 at 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.
Sergey Alexandrovich Kryukov at 9-May-13 0:18am
   
Too bad, for you. You are not collaborative. No more help, sorry.
—SA
Member 9339684 at 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.
Sergey Alexandrovich Kryukov at 9-May-13 1:18am
   
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.
—SA
Member 9339684 at 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.
Sergey Alexandrovich Kryukov at 9-May-13 1:27am
   
Thank you, case closed...
—SA
Member 9339684 at 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
0 OriginalGriff 240
1 Kamal Rocks 184
2 BillWoodruff 173
3 PIEBALDconsult 160
4 CPallini 155
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2014
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