Click here to Skip to main content
15,921,203 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi i have a check box in which i have binded 5 listitems dynamically,now i want to store the value of those list items not text into the database ,i have tried too much so try to help me out of this .
thanks in advance


my some code i think itr is understandable

string inputvalue = null;
       int I = 0;
       for (I = 0; I <= chk_contentmod.Items.Count - 1; I++)
       {
           if (chk_contentmod.Items[I].Selected == true)
           {
               inputvalue = chk_contentmod.Items[I].value;

           }
               if (imgbtn_save.AlternateText == "Save")
               {

                   //csd.ResponsibilityID = Convert.ToInt64(chk)
                   csd.Name= txt_name.Text;
                   csd.PostID = Convert.ToInt64(drp_post.SelectedValue);
                   csd.MaintenancecategoryID = (inputvalue);
                   csd.IsEditMember = Convert.ToInt64(rdbtn_caneditupdate.SelectedValue);

                   object result = csd.insert();


               }
           }

       }


but this code is not working ,any value is not being inserted into the database.
Posted
Updated 9-Apr-12 1:54am
v3
Comments
[no name] 9-Apr-12 7:54am    
Format code snippets
[no name] 9-Apr-12 7:56am    
What is csd? Remember we are not sitting next time working on the same project.
shek124 9-Apr-12 8:16am    
HAve you got any exception..
There is one extra bracket in the code......
Sergey Alexandrovich Kryukov 9-Apr-12 12:35pm    
And where is your database-related code? Did you run it under debugger?
--SA

1 solution

Nobody knows what all those declarations you use here mean. Probably, you somehow don't know what is relevant to your question and what is not. I cannot see any code which would certainly be related to a database. Also, check boxes need checking Checked or IsChecked property. There is nothing like that in this code sample.

First of all, you need to run your code under debugger, at least before asking such questions. In fact, you need to do that in case of a slightest concern about your run time behavior.

The code shows that you don't really understand what are your writing. The condition if (chk_contentmod.Items[I].Selected == true) looks ridiculous, because Selected is already a predicate (Boolean property), so it could be if (chk_contentmod.Items[I].Selected)….

The comparison imgbtn_save.AlternateText == "Save" is not supportable. Should you ever change the UI and — bye-bye… What is that untyped object result? Why? Naming of variables and members is horrific…

—SA
 
Share this answer
 
Comments
VJ Reddy 9-Apr-12 12:56pm    
Good analysis of the question. +5
Sergey Alexandrovich Kryukov 10-Apr-12 12:31pm    
Thank you, VJ.
--SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900