插入复选框的最低值 [英] Insert checkboxlest values

查看:60
本文介绍了插入复选框的最低值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有一个复选框,其中我动态绑定了5个列表项,现在我想将这些列表项(而不是文本)的值存储到数据库中,我已经尝试了太多,所以请尝试帮我解决这个问题.
在此先感谢


我的一些代码我认为是可以理解的

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();


               }
           }

       }



但是此代码不起作用,没有将任何值插入数据库.

解决方案

没人知道您在此处使用的所有声明的含义.可能是,您以某种方式不知道与您的问题相关的内容,而与您的问题无关的内容.我看不到任何肯定与数据库相关的代码.此外,复选框需要检查CheckedIsChecked属性.此代码示例中没有类似的内容.

首先,至少在询问此类问题之前,您需要在调试器下运行代码.实际上,如果对运行时行为稍有担心,就需要这样做.

该代码表明您并不真正理解自己的写作.条件if (chk_contentmod.Items[I].Selected == true)看起来很荒谬,因为Selected已经是一个谓词(布尔属性),所以如果(chk_contentmod.Items[I].Selected)…可能就是这样.
比较imgbtn_save.AlternateText == "Save"不支持.您是否应该更改UI并(再见)……未键入的object result是什么?为什么?变量和成员的命名太可怕了...

—SA


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.

解决方案

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


这篇关于插入复选框的最低值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆