forum

Home / DeveloperSection / Forums / jQuery dropdownchecklist doesn't binds data

jQuery dropdownchecklist doesn't binds data

Anonymous User 3260 28-Aug-2014

I am trying to bind(select) the some data by value from my list but it is not possible. 

As you can see I store them by this value:

DataValueField="ID_PROJECT_TYPE_DETAILS"

I have the following html code:

<asp:ListBox SelectionMode="Multiple" ID="DDLProjectDetails" runat="server"
                        DataSourceID="SqlDataSource4" DataTextField="DESCRIPTION"
                        DataValueField="ID_PROJECT_TYPE_DETAILS">
                                    </asp:ListBox>
 
                    <script type="text/javascript">
                        $(document).ready(function () {
                            $('#<%= DDLProjectDetails.ClientID %>').dropdownchecklist({ width: 248 });
                        });
                    </script>
 
                    <asp:SqlDataSource ID="SqlDataSource4" runat="server"
                        ConnectionString="<%$ ConnectionStrings:MesarchConnectionString %>"
                        SelectCommand="SELECT * FROM [PROJECT_TYPE_DETAILS]"></asp:SqlDataSource>

and the code behind code:

string insCmd = "SELECT ID_PROJECT, ID_PROJECT_TYPE_DETAILS FROM PROJECT_TYPE_DETAILS_OF_PROJECT WHERE ID_PROJECT = @IDProject";
 dr = com.ExecuteReader();
            while (dr.Read())
            {
                if (DDLProjectDetails.Items.Contains(DDLProjectDetails.Items.FindByValue(dr.GetInt32(1).ToString())))
                    DDLProjectDetails.Items.FindByValue(dr.GetInt32(1).ToString()).Selected = true;
            }

and doesn't fills my dropdownchecklist like this: enter image description here

When I run the program my DDLProjectDetails doesn't shows that has any items.


Updated on 28-Aug-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By