ASPxComboBox 设置值
ASPxComboBox set value
我想在页面加载事件中设置数据库中的值。我尝试了很多方法,但没有发生。你能帮忙吗
<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"];
我想select从数据库中获取数据库的值但是它只写入传入的值。
我相信你可以使用ASPxComboBox.Value属性来完成你的任务。
尝试使用下面的代码片段:
ASPxComboBox1.Value = Convert.ToString(dt.Rows[0]["SubKategoriid"]);
参考这些:
ASPxComboBox , How to set selected item?
ASPxComboBox - How to set selected value on load
Set ASPxComboBox selected value at runtime
如果您遇到其他问题,请提供更多详细信息。
我想在页面加载事件中设置数据库中的值。我尝试了很多方法,但没有发生。你能帮忙吗
<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"];
我想select从数据库中获取数据库的值但是它只写入传入的值。
我相信你可以使用ASPxComboBox.Value属性来完成你的任务。
尝试使用下面的代码片段:
ASPxComboBox1.Value = Convert.ToString(dt.Rows[0]["SubKategoriid"]);
参考这些:
ASPxComboBox , How to set selected item?
ASPxComboBox - How to set selected value on load
Set ASPxComboBox selected value at runtime
如果您遇到其他问题,请提供更多详细信息。