Jump to content
Xtreme .Net Talk

Misha

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Misha

  1. Thank you! I changed the code and it works fine now.
  2. Mike55, I used the following tag to do the same thing: <head> <META HTTP-EQUIV="refresh" content="3;URL=http://www.google.com"> </head> number "3" specifies the time in seconds before redirecting.
  3. Hi! I have the folloving strange problem with editing data in the DataGrid. I can pull data from the database, show them and put in to the edit mode. Let's say I have to change some record from "green" to "red". When I change value in the text box and click update, data is updated in the database, and it has new "red" value, but on the screen I still see the old value "green". If I click on update again, the newly submited value "red" appears in the text box. Please, take a look at the code below. Thank you in advance! void Page_Load(Object sender, EventArgs e) { SqlConnection myConnection = new SqlConnection("server=**;user=**;password=**;database=**;"); SqlDataAdapter myCommand = new SqlDataAdapter("SELECT * from Interface WHERE ID= " + recID, myConnection); DataSet EditDS = new DataSet(); myCommand.Fill(EditDS, "RoomEdit"); EditDW = new DataView(); EditDW = EditDS.Tables["RoomEdit"].DefaultView; EditGrid.DataSource = EditDW; if (!Page.IsPostBack) { EditGrid.DataBind(); } } void BindGrid() { EditGrid.DataSource = EditDW; EditGrid.DataBind(); } void EditGrid_Update(Object sender, DataGridCommandEventArgs e) { TextBox RoomUseDescTextB = (TextBox)e.Item.Cells[9].Controls[0]; TextBox RoomUseCdTextB = (TextBox)e.Item.Cells[10].Controls[0]; String newRoomUseCd = RoomUseCdTextB.Text; String newRoomUseDesc = RoomUseDescTextB.Text; SqlConnection connUpdate = new SqlConnection("server=**;user=**;password=**;database=**;"); connUpdate.Open(); String sql_edit = "UPDATE Interface " + "SET RoomUseCode = '" + newRoomUseCd + "', " + "RoomUseDesc = '" + newRoomUseDesc + "'" + " WHERE ID = " + e.Item.Cells[0].Text; SqlCommand sqlCommandUpdate = new SqlCommand(sql_edit,connUpdate); sqlCommandUpdate.ExecuteNonQuery(); connUpdate.Close(); EditGrid.EditItemIndex = -1; BindGrid(); }
×
×
  • Create New...