简体   繁体   English

ASPxComboBox设置值

[英]ASPxComboBox set value

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. 我想从数据库中选择数据库的值,但它只写输入值。

I believe that you can use the ASPxComboBox.Value Property to accomplish your task. 我相信您可以使用ASPxComboBox.Value属性来完成您的任务。

Try to use the below code snippet: 尝试使用以下代码段:

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

Refer these: 请参考以下内容:
ASPxComboBox , How to set selected item? ASPxComboBox,如何设置所选项目?
ASPxComboBox - How to set selected value on load ASPxComboBox-如何在加载时设置所选值
Set ASPxComboBox selected value at runtime 在运行时设置ASPxComboBox选定的值

If you facing some other problem then provide more details. 如果您遇到其他问题,请提供更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM