0

I want to set the value in the database in the page load event. I tried many ways but it did not happen. Could you help.

   <dx:ASPxComboBox ID="ASPxComboBox3" IncrementalFilteringMode="None"  runat="server" DropDownStyle="DropDownList" Height="30px" DataSourceID="SqlDataSource3" TextField="SubKategoriAdi" ValueField="SubKategoriid" Enabled="True" SettingsLoadingPanel-Text="Lütfen bekliyiniz">
              </dx:ASPxComboBox>
                  <asp:SqlDataSource runat="server" ID="SqlDataSource3" ConnectionString='<%$ ConnectionStrings:baglan %>' SelectCommand="SELECT * FROM [SubKategoriler]"></asp:SqlDataSource>

-

SqlConnection bagla = new SqlConnection(ConfigurationManager.ConnectionStrings["baglan"].ConnectionString);
        bagla.Open();
        SqlDataAdapter komut = new SqlDataAdapter("select * from urunler where  id='" + Temizle(Request.QueryString["id"].ToString()) + "'", bagla);
        DataTable dt = new DataTable();
        komut.Fill(dt);  
ASPxComboBox1.Value = dt.Rows[0]["SubKategoriid"];

I want to select the value of the database from the database but it only writes the incoming value.

fabis
  • 3
  • 7

1 Answers1

0

I believe that you can use the ASPxComboBox.Value Property to accomplish your task.

Try to use the below code snippet:

ASPxComboBox1.Value = Convert.ToString(dt.Rows[0]["SubKategoriid"]);

Refer these:
ASPxComboBox , How to set selected item?
ASPxComboBox - How to set selected value on load
Set ASPxComboBox selected value at runtime

If you facing some other problem then provide more details.

Niranjan Singh
  • 18,017
  • 2
  • 42
  • 75
  • 1
    when I use the value it brings the value in the ComboBox. The value is not equal to the text. – fabis May 31 '18 at 10:03