Here is my csfile:
protected void GridViewStudent_SelectedIndexChanged(object sender, EventArgs e)
{
btnupdate.Visible = true;
}
protected void btnupdate_Click(object sender, EventArgs e)
{
try
{
OleDbConnection con = Connection.DBconnection();
con.Open();
string SID = lblSID.Text;
OleDbCommand com = new OleDbCommand("UPDATE registration set(username=@username,pwd=@pwd;address=@address,phone=@phone,email=@email,qualification=@qualification where SID=@SID", con);
com.Parameters.AddWithValue("@username", Textusername.Text.Trim());
com.Parameters.AddWithValue("@pwd", Textpwd.Text.Trim());
com.Parameters.AddWithValue("@email", Textemail.Text.Trim());
com.Parameters.AddWithValue("@phone", Textphone.Text.Trim());
com.Parameters.AddWithValue("@address", Textaddress.Text.Trim());
com.Parameters.AddWithValue("@qualification", Textqualification.Text.Trim());
com.Parameters.AddWithValue("SID", SID);
com.ExecuteNonQuery();
com.Dispose();
ShowMessage("Student Data update Successfully......!");
GridViewUser.EditIndex = -1;
BindGridView();
btnupdate.Visible = false;
}
catch (Exception ex)
{
ShowMessage(ex.Message);
}
finally
{
OleDbConnection con = new OleDbConnection(connectionstr);
if (con.State == ConnectionState.Open)
{
con.Close();
}
}
}
aspx file:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="registrationuser.aspx.cs" Inherits="registration.registrationuser" %>
<asp:Button ID="btnupdate" runat="server" Text="Update" visible="false" OnClick="btnupdate_Click"Height="30px" Width="75px" Font-Size="15px" ForeColor="#0094ff" BackColor="white" />
When i run the above code,it shows error like this,
The name 'btnupdate' doesn't exist in current context
I m new to .net, please don't mind if any mistake in my code.
Can you please guide me to fix this issue?
Thanks,