protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
int id = Convert.ToInt32(((Label)(GridView1.Rows[e.RowIndex].FindControl("lbl_AssetID"))).Text);
//TextBox txtId = (TextBox)(GridView1.Rows[e.RowIndex].FindControl("txtAssteId"));
//TextBox txtItemid = (TextBox)(GridView1.Rows[e.RowIndex].FindControl("txtItemId"));
TextBox txtName = (TextBox)(GridView1.Rows[e.RowIndex].FindControl("txtAssetName"));
TextBox txtAssetData = (TextBox)(GridView1.Rows[e.RowIndex].FindControl("txtAssetData"));
DropDownList ddlType = (DropDownList)(GridView1.Rows[e.RowIndex].FindControl("ddlAsetType"));
DropDownList ddlSubType = (DropDownList)(GridView1.Rows[e.RowIndex].FindControl("ddlSubType"));
TextBox txtAssetFilepath = (TextBox)(GridView1.Rows[e.RowIndex].FindControl("txtAssetFilePath"));
//Session["txtItem"] = txtItemid.Text;
Session["AssetId"] = id;
string sqlUpdate = "Update assets set AssetType='" + ddlType.SelectedItem.Text + "',AssetSubType='" + ddlSubType.SelectedItem.Text + "',AssetName='" + txtName.Text + "',AssetData='" + txtAssetData.Text + "',AssetFilePath='" + txtAssetFilepath.Text + "' where AssetId='" + id + "'";
if (myConnection.State == ConnectionState.Closed)
{
myConnection.Open();
}
//OdbcCommand myCommand = new OdbcCommand(sqlUpdate, myConnection);
command = new MySqlCommand(sqlUpdate, myConnection);
command.CommandType = CommandType.Text;
command.CommandText = sqlUpdate;
command.ExecuteNonQuery();
myConnection.Close();
lblMsg.Visible = true;
lblMsg.Text = "Asset Updated Successfully.";
BindGrid();
Response.Redirect("AssetViewer.aspx?Sucess=" + "message");
}
catch (Exception ex)
{
lblMsg.Visible = true;
lblMsg.Text = ex.Message;
}
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindGrid();
}