How to manually bind data to dropdownlist (hard coded)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • denvercr
    New Member
    • Aug 2006
    • 13

    How to manually bind data to dropdownlist (hard coded)

    hi guys just want to get input from you on how can i bind data to a dropdownlist manually or in hard code?..

    How can I use ObjectDataSourc e for this binding? or is there any other way?..

    Thanks..
  • pintum
    New Member
    • Aug 2006
    • 3

    #2
    How to bind data to dropdownlist (hard coded) ,send the Code of this forum

    Comment

    • pintum
      New Member
      • Aug 2006
      • 3

      #3
      Please send the code immidiate

      Comment

      • denvercr
        New Member
        • Aug 2006
        • 13

        #4
        Hi Pintum,

        Im so sorry for this late reply. I was out of the office already when you responded to my post on how can i possibly bind data to dropdownlist. Hope you could stil help me out.

        Here is my code when Im trying to use ObjectDataSourc e to bind data to dropdownlist. I tried to run this in Visual Web Developer but I cannot figure out the error. I just patterned this code on tags on autamatically created by the IDE.

        Dim filterByQuarter Adapter As New filterSaveTrain ingResult_DataS etTableAdapters .searchSaveDist inctQuarter_Tab leAdapter

        Dim filterDistinctQ uarter_ObjectDa taSource AsNew ObjectDataSourc e
        filterDistinctQ uarter_ObjectDa taSource.ID = "filterDistinct Quarter_ObjectD ataSource"
        filterDistinctQ uarter_ObjectDa taSource.OldVal uesParameterFor matString = "original_{ 0}"
        filterDistinctQ uarter_ObjectDa taSource.Select Method = "filterByQuarte rAdapter.GetDat a_ByQuarter"


        Me.filterResult _DropDownList.D ataSourceID = "filterDistinct Quarter_ObjectD ataSource"
        Me.filterResult _DropDownList.D ataTextField = "quarter"
        Me.filterResult _DropDownList.D ataValueField = "quarter"


        Me.filterResult _DropDownList.D ataSource = filterByQuarter Adapter.GetData _ByQuarter.Data Set


        If its confusing to you about the code, Is there a way I can send the proper arrangement of code to you so you can read it clearly? thank you so much.. you can reply direct on my email add at: denver.crisosto mo@dhl.com. I will be waiting for your reply..

        Comment

        • nmsreddi
          Contributor
          • Jul 2006
          • 366

          #5
          hi

          u can bind data dynamically from datadase by suing dataset,

          SqlConnection con=new SqlConnection(" connection string");
          SqlCommand cmd =new SqlCommand("que ry",con);
          DataSet ds=new DataSet();
          SqlDataAdapter da=new SqlDataAdapter( cmd);
          da.Fill(ds);
          DataTable dt=new DataTable();
          dt=ds.Tables[0];
          DropDownList1.D ataSource=dt;
          DropDownList1.D ataTextField=dt .Columns[1].ColumnName;

          DropDownList1.D ataBind();



          this is comple code in c# al the best


          regards

          nmsreddi

          Comment

          • denvercr
            New Member
            • Aug 2006
            • 13

            #6
            hi nmreddi,

            very good idea!!! =) thank you so much..

            regards to you.

            Comment

            Working...