B
Bhagya
DataSet ds = new DataSet();
DataTable dtAddUsers = new DataTable("Names");
public void CreateDataset()
{
dtAddUsers.Columns.Add("Name", typeof(String));
dtAddUsers.Columns.Add("Place", typeof(String));
ds.Tables.Add(dtAddUsers);
ViewState["Dataset"] = ds;
}
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
CreateDataset();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds = (DataSet)ViewState["Dataset"];
DataRow dr = ds.Tables[0].NewRow();
dr["Name"] = TextBox1.Text;
dr["Place"] = TextBox2.Text;
ds.Tables[0].Rows.Add(dr);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
ViewState["Dataset"] = ds;
TextBox1.Text = string.Empty;
TextBox2.Text = string.Empty;
}
protected void GridView1_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
DataSet ds = new DataSet();
ds = (DataSet)ViewState["Dataset"];
ds.Tables[0].Rows.RemoveAt(e.RowIndex);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
protected void GridView1_RowEditing(object sender,
GridViewEditEventArgs e)
{
DataSet ds = new DataSet();
ds = (DataSet)ViewState["Dataset"];
GridView1.EditIndex = e.NewEditIndex;
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
protected void GridView1_RowCancelingEdit(object sender,
GridViewCancelEditEventArgs e)
{
DataSet ds = new DataSet();
ds = (DataSet)ViewState["Dataset"];
GridView1.EditIndex = -1;
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
Can anybody give code for GridView1_RowUpdating()
DataTable dtAddUsers = new DataTable("Names");
public void CreateDataset()
{
dtAddUsers.Columns.Add("Name", typeof(String));
dtAddUsers.Columns.Add("Place", typeof(String));
ds.Tables.Add(dtAddUsers);
ViewState["Dataset"] = ds;
}
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
CreateDataset();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds = (DataSet)ViewState["Dataset"];
DataRow dr = ds.Tables[0].NewRow();
dr["Name"] = TextBox1.Text;
dr["Place"] = TextBox2.Text;
ds.Tables[0].Rows.Add(dr);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
ViewState["Dataset"] = ds;
TextBox1.Text = string.Empty;
TextBox2.Text = string.Empty;
}
protected void GridView1_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
DataSet ds = new DataSet();
ds = (DataSet)ViewState["Dataset"];
ds.Tables[0].Rows.RemoveAt(e.RowIndex);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
protected void GridView1_RowEditing(object sender,
GridViewEditEventArgs e)
{
DataSet ds = new DataSet();
ds = (DataSet)ViewState["Dataset"];
GridView1.EditIndex = e.NewEditIndex;
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
protected void GridView1_RowCancelingEdit(object sender,
GridViewCancelEditEventArgs e)
{
DataSet ds = new DataSet();
ds = (DataSet)ViewState["Dataset"];
GridView1.EditIndex = -1;
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
Can anybody give code for GridView1_RowUpdating()