Monday, March 26, 2012

May I ask a question?

How to separate page list data in Datalist web controls?
Could you tell us a little more about what you are trying to do?

I want to read data from database and fill in dataList web controls.
But the data items is too many in database and result in the page list very long!
So i want to know,How to pagination list data items in dataList web controls?
Thanks!!!


Hello, what you need is paging a DataList. Please check this article, it will help you with your goal:
Paging a DataList
Regards

When i run my project,no error and exception been happen.
But it couldn't update the data items in datagrid webcontrols!
Please help me ,Where is error!
Thanks!
---------------------------------------
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{

TextBox aTextBox=(TextBox)e.Item.Cells[2].Controls[0];
int myID=System.Int16.Parse(this.DataGrid1.DataKeys[this.DataGrid1.EditItemIndex].ToString());

SqlConnection myCon=new SqlConnection("Server=HUOZHIYONG;database=net;UID=sa;PWD=sa");
string sql="Update news Settitle=@.title Whereid=@.ID";
SqlCommand myCom=new SqlCommand( );
myCom.CommandType=CommandType.Text;
myCom.CommandText=sql;
myCom.Connection=myCon;
myCom.Parameters.Add(new SqlParameter("@.title",SqlDbType.NVarChar));
myCom.Parameters["@.title"].Value=aTextBox.Text;
myCom.Parameters.Add(new SqlParameter("@.ID",SqlDbType.Int));
myCom.Parameters["@.ID"].Value=myID;

try
{
myCon.Open();
myCom.ExecuteNonQuery();

myCon.Close();


}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
this.DataGrid1.EditItemIndex=-1;
this.DataGrid1.DataBind();
}

0 comments:

Post a Comment