看看http://expert.csdn.net/Expert/topic/2214/2214307.xml?temp=.6608087
解决方案 »
- 怎么使用sql语句查询日期所在周的一周各天
- 求 多张图片以及文字定时播放功能!
- 怪事,求解!
- Gridview绑定数据,哪种方法效率高?数据控件还是IEnumerable (Of T)
- 急高分求助!!!!求助!!!!求助!!!!
- 哪位给推荐本asp.net(中文版,c#)电子书&下载地址--[注;宁缺勿滥]
- javascript设置div的列表,单击列表后页面刷新页面又把div自动合起
- 各位老兄,請問這是怎么囬事?????
- 求DES不对称加密解密算法的源码
- 谁来帮我,郁闷的要死呀!解决了可以另开帖给分!
- DataGrid编辑更新后刷新DataGrid的问题
- 每个子目录下都设置web.config,这些子目录都必须是web的虚拟目录吗?
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!Page.IsPostBack)
{
string varsql = "select * from product";
myconnclass myclass =new conndbdll.myconnclass();
SqlDataReader myreader=myclass.ExecuteReader(varsql);
DropDownList1.DataSource = myreader;
DropDownList1.DataTextField = "name";
DropDownList1.DataValueField = "id";
DropDownList1.DataBind();
varsql = "select * from productname";
myreader=myclass.ExecuteReader(varsql);
DropDownList2.DataSource = myreader;
DropDownList2.DataTextField = "name";
DropDownList2.DataValueField = "cid";
varsql = "select * from name where cname<>'admin'";
myreader=myclass.ExecuteReader(varsql);
DropDownList3.DataSource = myreader;
DropDownList3.DataTextField = "cname";
DropDownList3.DataValueField = "id";
DropDownList3.DataBind();
DataGrid1.CurrentPageIndex = 0;
binddatagrid();
}
}public void changecode(object objsender,EventArgs e)
{
//在此处放置连动下拉菜单的过程
string varsql = "select * from productname where cid=" + this.DropDownList1.SelectedItem.Value;
myconnclass myclass =new conndbdll.myconnclass();
SqlDataReader myreader=myclass.ExecuteReader(varsql);
DropDownList2.DataSource = myreader;
DropDownList2.DataTextField = "name";
DropDownList2.DataValueField = "cid";
DropDownList2.DataBind();
}
public void add(object objsender, EventArgs e)
{
//此处是点击添加按钮的响应过程
string varsql = "insert into telrecord(kebordman,username) values ('zxz','" + username.Text + "')";
myconnclass myclass =new conndbdll.myconnclass();
int myrows=myclass.ExecuteNonQuery(varsql);
binddatagrid();
}
public void changegridpage(object sender, DataGridPageChangedEventArgs objargs)
{
//此处是datagrid分页响应过程
DataGrid1.CurrentPageIndex = objargs.NewPageIndex;
binddatagrid();
}
public void sortrows(object sender, DataGridSortCommandEventArgs objargs)
{
//此处是datagrid排序响应过程
sortorder = objargs.SortExpression.ToString();
binddatagrid();
}
public void binddatagrid()
{
//此处是gatagrid的数据绑定过程
DataGrid1.PageSize = 5;
DataGrid1.PagerStyle.Mode = PagerMode.NumericPages;
string varsql = "select * from telrecord";
myconnclass myclass =new conndbdll.myconnclass();
string mytable="mytable";
DataSet mydataset=myclass.DataAdapter(varsql,mytable);
DataView mydataview = new DataView(mydataset.Tables["mytable"]);
//mydataview.Sort = sortorder;
DataGrid1.DataSource = mydataview;
DataGrid1.DataBind();
}
public void doitemedit(object objsource,DataGridCommandEventArgs objargs)
{
//单击datagrid的编译按钮响应过程
DataGrid1.EditItemIndex = objargs.Item.ItemIndex;
binddatagrid();
}
public void doitemcancel(object objsource, DataGridCommandEventArgs objargs)
{
//单击datagrid的取消按钮响应过程
DataGrid1.EditItemIndex = -1;
binddatagrid();
}
public void doitemupdate(object objsource, DataGridCommandEventArgs e)
{
//单击datagrid的更新按钮响应过程
TextBox objproductctrl = (TextBox)e.Item.FindControl("txtmethod");
string varsql = "UPDATE telrecord SET method='" + objproductctrl.Text + "' where id=" + this.DataGrid1.DataKeys[e.Item.ItemIndex];
myconnclass myclass =new conndbdll.myconnclass();
int myrows=myclass.ExecuteNonQuery(varsql);
DataGrid1.EditItemIndex = -1;
binddatagrid();
}