当前位置: 移动技术网 > IT编程>开发语言>.net > asp.net ListView 数据绑定

asp.net ListView 数据绑定

2018年04月18日  | 移动技术网IT编程  | 我要评论

直播吧 nba,答题网,世界杯今日赛程

代码如下:
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);
}
}
}
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网