类文件中的DataGrid的设置!
我在类文件里定义了一个DataGrid,样式什么的也自己写了一部分,但是当写有DataGrid有事件的时候却不知道如何写?请大家帮忙!
public static string GetDataTable()
{
DataTable dt = new DataTable();
string sql = "select * from users ";
dt = DataAccess.SqlDataAccess.ExeForDataTable(sql);
DataGrid dg = new DataGrid();
dg.AllowPaging = true;
dg.PagerStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;
dg.PagerStyle.Mode = System.Web.UI.WebControls.PagerMode.NumericPages;
dg.PageSize = 2;
dg.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
dg.AlternatingItemStyle.BackColor = System.Drawing.Color.DarkRed;
dg.ItemStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
dg.Width = System.Web.UI.WebControls.Unit.Pixel(400);
dg.HeaderStyle.BackColor = Color.Green;
dg.HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
dg.DataSource = dt;
dg.DataBind();
System.Text.StringBuilder strb = new System.Text.StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter(strb);
System.Web.UI.HtmlTextWriter htw = new HtmlTextWriter(sw);
dg.RenderControl(htw);
string s = strb.ToString();
return s;
}
------解决方案--------------------爽!登录的时候验证码是88888!我有时间研究一下了!