using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace www
{
public class updateMyCodeBehind : Page
{
public DataGrid MyList;
public DropDownList DropDownList1;
public DropDownList DropDownList2;
public TextBox TextBox1;
public LinkButton btnFirst;
public LinkButton btnPrev;
public LinkButton btnNext;
public LinkButton btnLast;
public Label lblCurrentPage;
public Label lblPageCount;
public Label lblRecordCount;
public TextBox txtIndex;
DataView CreateDataSource()
{
SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter myCommand = new SqlDataAdapter("select * from aa WHERE typeid="+ DropDownList2.SelectedItem.Value+" order by shijian desc", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "aa");
return ds.Tables["aa"].DefaultView;
}
PageCount=Int32.Parse(lblPageCount.Text.ToString());
int pageindex=Int32.Parse(lblCurrentPage.Text.ToString())-1;
switch(arg)
{
case "Next":
if (pageindex < (PageCount - 1))
pageindex ++;
break;
case "Prev":
if (pageindex > 0)
pageindex --;
break;
case "Last":
pageindex = (PageCount - 1);
break;
case "First":
pageindex=0;
break;
}
if(pageindex==0)
{
btnFirst.Enabled=false;
btnPrev.Enabled=false;
}
else if(pageindex==PageCount-1)
{
btnLast.Enabled=false;
btnNext.Enabled=false;
}
MyList.CurrentPageIndex=pageindex;
DataBind();
lblCurrentPage.Text=(MyList.CurrentPageIndex+1).ToString();
}
public void SubmitBtn_Click(Object sender, EventArgs e)
{
{
SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter myCommand = new SqlDataAdapter("select * from aa where " + DropDownList1.SelectedItem.Value + " like '%" + TextBox1.Text.ToString() + "%'", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "tt");
public void MyDataGrid_Delete(Object sender, DataGridCommandEventArgs e)
{
SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
String deleteCmd = "DELETE from aa where id = @Id";
SqlCommand myCommand = new SqlCommand(deleteCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@Id", SqlDbType.Char, 11));
myCommand.Parameters["@Id"].Value = MyList.DataKeys[(int)e.Item.ItemIndex];