国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net ListView 數據綁定

2024-07-10 12:39:18
字體:
來源:轉載
供稿:網友
代碼如下:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string strsql = @"server=.;uid=sa;pwd=sa;database=Northwind";
SqlConnection my_Conn = new SqlConnection(strsql);
my_Conn.Open();
string str_sql ="select * from employeesTable";
// DataSet my_Dataset = new DataSet();
// SqlCommand my_comm = new SqlCommand(str_sql, my_Conn);
// SqlDataAdapter sql_Adapter = new SqlDataAdapter(str_sql, my_Conn);
//sql_Adapter.Fill(my_Dataset,"employeesTable");
SqlCommand my_Comm = new SqlCommand(str_sql, my_Conn);
SqlDataReader reader = my_Comm.ExecuteReader();
while (reader.Read())
{
ListViewItem viewitem = new ListViewItem(reader[0].ToString());
viewitem.ImageIndex = 0;
viewitem.SubItems.Add(reader[1].ToString());
viewitem.SubItems.Add(reader[2].ToString());
listView1.Items.Add(viewitem);
}
}
private void BtnSearch_Click(object sender, EventArgs e)
{
int mystartindex = 0;///
int Count = Convert.ToInt32(this.textBox1.Text);
ListViewItem Item = listView1.FindItemWithText(textBox1.Text,true,mystartindex);
try
{
if (textBox1.Text != null)
// if (Count>=listView1.Items.Count)
{
listView1.Focus();
Item.Selected = true;
mystartindex = mystartindex + 1;
}
else
{
MessageBox.Show("沒有您要的數據");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 娄烦县| 万州区| 中卫市| 石景山区| 南靖县| 扬中市| 龙里县| 晴隆县| 宜兰县| 岑巩县| 金寨县| 桐乡市| 安新县| 舟山市| 育儿| 德保县| 新乐市| 新河县| 弥勒县| 济宁市| 云霄县| 盐亭县| 东台市| 葵青区| 威宁| 石景山区| 务川| 额济纳旗| 德州市| 甘泉县| 永德县| 玛曲县| 湖口县| 安达市| 东安县| 阿合奇县| 简阳市| 哈巴河县| 休宁县| 鸡东县| 平泉县|