如何在asp.net c中按钮单击时将值从列表框传递到文本框# [英] how to pass value from listbox to textbox on button click in asp.net c#

查看:205
本文介绍了如何在asp.net c中按钮单击时将值从列表框传递到文本框#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将值从列表框传递到文本框按钮点击asp.net c#





i使用了两个文本框。当我单击列表框一项然后传递它们的值文本框如何?

how to pass value from listbox to textbox on button click in asp.net c#


i used two text box .when i click list box one item then pass their values textbox how?

推荐答案

SqlConnection con = new SqlConnection(strcon);

con.Open( );

string str =select * from table name where query_name ='+ LstBox_query_out.SelectedItem +';

cmd = new SqlCommand(str,con) ;

da = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();

da.Fill(ds);



if(ds.Tables [0] .Rows.Count> 0)

{

DataRow dr = ds.Tables [0] .Rows [0];

txt_query_name.Text = dr [query_name]。ToString();

txt_query.Text = dr [查询]。ToString();



}
SqlConnection con = new SqlConnection(strcon);
con.Open();
string str = "select * from table name where query_name='" + LstBox_query_out.SelectedItem + "'";
cmd = new SqlCommand(str, con);
da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);

if (ds.Tables[0].Rows.Count > 0)
{
DataRow dr = ds.Tables[0].Rows[0];
txt_query_name.Text = dr["query_name"].ToString();
txt_query.Text = dr["query"].ToString();

}


这篇关于如何在asp.net c中按钮单击时将值从列表框传递到文本框#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆