using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data;using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {
bind_data(); } protected void Button1_Click(object sender, EventArgs e) { } protected void x_SelectedIndexChanged(object sender, EventArgs e) {
} protected void editdata(object source, DataGridCommandEventArgs e) { x.EditItemIndex = e.Item.ItemIndex; bind_data(); } public void bind_data() { SqlConnection conn = new SqlConnection("server=CHN-W2K-SYS067;uid=sa;pwd=;Database=pubs"); conn.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM Titles", conn); x.DataSource = cmd.ExecuteReader(); x.DataBind(); } protected void canceldata(object source, DataGridCommandEventArgs e) { x.EditItemIndex = -1; bind_data(); } protected void updatedata(object source, DataGridCommandEventArgs e) { TextBox newtitle = new TextBox(); // string titleid = x.DataKeys[e.Item.ItemIndex].ToString(); newtitle =(TextBox) e.Item.Cells[0].Controls[0]; Response.Write(newtitle.Text); }}
<%
<!
<
</