gridview not recognized


J

JohnE

I have a formview with a gridview inside of it. In the C# code behind the
page (listed below) the line of gvwEditChildren.Databind, I get the following
error message;

The name 'gvwEditChildren' does not exist in the current context.

The gridview exists. If I do not use the code behind, it runs fine except
the linkbutton for insert doesnot work. The gridview is populated by a
sqldatasource. I tried the 'No Build' for start options but it still errors
out. Intellisent also is not showing it.

protected void gvwEditChildren_RowCommand(object sender,
GridViewCommandEventArgs e)
{
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["ProteusConnectionString"].ConnectionString);
try
{
if (e.CommandName.Equals("Insert"))
{
LinkButton lbtnInsert = e.CommandSource as LinkButton;
GridViewRow row = lbtnInsert.NamingContainer as GridViewRow;
if (row == null)
{
return;
}
DropDownList ddlIsChildOfEdit =
row.FindControl("ddlIsChildOfEdit") as DropDownList;
SqlCommand cmd = new SqlCommand("INSERT INTO
[tblChangeRequest] ([IsChildOf] VALUES (@ChangeRequestID)", conn);
cmd.Parameters.AddWithValue("ChangeRequestID",
ddlIsChildOfEdit.SelectedValue);
conn.Open();
if (cmd.ExecuteNonQuery() == 1)
{
gvwEditChildren.DataBind();
}
}
}
catch (Exception ex)
{

}
finally
{
conn.Close();
}

Has anyone come across this error message before?
Thanks.
John
 
Ad

Advertisements


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

Similar Threads


Top