Update

V

Vannela

I am new ASP.NET so please help me in clearing my doubt
I have got a DataGrid into which i am retrievinh few
column of a table from a database. I have used
Edit,Update,Cancel column to edit and update the row .
I am able to edit a row but unable to update it to
database?

How should i update it to database?



private void Page_Load(object sender, System.EventArgs e)
{

if(! IsPostBack)
{
adapter = new SqlDataAdapter ("select * from
titles","server=sg12/NETSDK;Integrated
Security=SSPI;Persist Security Info=True;Initial
Catalog=pubs;Data Source=SG12\\NETSDK;Packet
Size=4096;Workstation ID=SG12;pwd=");

ds=new DataSet();
table=new DataTable("Titles");
adapter.Fill (ds, "Titles");
DataGrid1.DataSource=ds;
DataGrid1.DataBind ();

}
}

private void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex=e.Item.ItemIndex;
DatataGrid1.DataSource=ds;
DataGrid1.DataBind ();
}


private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//WHAT SHOUL I CODE HERE?


//int i = Convert.ToInt16(e.Item.Cells[1].Text);
// string s=e.Item.Cells[2].Text;
// object[] obj = {i,s};
// table.Rows.Add(obj);
// adapter.Update(table);
}

PLEASE GIVE ME THE INFORMATION AT THE EARLIEST
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top