c# - The name 'GridView1' does not exist in the current context Glossary.aspx.cs -


glossary.aspx

here html code site. plan add login people can edit table based upon active directory.

<!doctype html>  <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title spellcheck="true">lexis nexis glossary</title> </head> <body>     <form id="form1" runat="server">     <div style="margin-left: 720px">         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     </div>         <asp:sqldatasource id="tedglossary" runat="server" connectionstring="<%$ connectionstrings:glsry_taylor %>" selectcommand="select [termtext], [defnbr], [defvernbr], [deftext], [amplifyingexplanationtext], [seealsotext], [authoritativesrctext], [scopename], [domnname], [governancestatename], [lastupdttimestamp] [glossary] order [termtext]"></asp:sqldatasource>         <asp:gridview id="gridview1" runat="server"  allowpaging="true" allowsorting="true" autogeneratecolumns="false"             " datakeynames="termtext,defnbr,defvernbr" datasourceid="tedglossary" enablesortingandpagingcallbacks="true">             <columns>                 <asp:boundfield datafield="termtext" headertext="term" readonly="true" sortexpression="termtext" />                 <asp:boundfield datafield="defnbr" headertext="definition #" readonly="true" sortexpression="defnbr" />                 <asp:boundfield datafield="defvernbr" headertext="definition vers #" readonly="true" sortexpression="defvernbr" />                 <asp:boundfield datafield="deftext" headertext="definition" sortexpression="deftext" />                 <asp:boundfield datafield="amplifyingexplanationtext" headertext="amplifying explanation" sortexpression="amplifyingexplanationtext" />                 <asp:boundfield datafield="seealsotext" headertext="see also" sortexpression="seealsotext" />                 <asp:boundfield datafield="authoritativesrctext" headertext="authoritative source" sortexpression="authoritativesrctext" />                 <asp:boundfield datafield="scopename" headertext="scope name" sortexpression="scopename" />                 <asp:boundfield datafield="domnname" headertext="domn name" sortexpression="domnname" />                 <asp:boundfield datafield="governancestatename" headertext="governance state" sortexpression="governancestatename" />                 <asp:boundfield datafield="lastupdttimestamp" headertext="last update" sortexpression="lastupdttimestamp" />             </columns>         </asp:gridview>     </form>     <script>         $(function () {             $('#<%=gridview1.clientid%>').datatable();         });     </script>  </body> </html> 

glossary.aspx.cs

using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols;  namespace home {     public partial class glossary : system.web.ui.page     {         protected void page_load(object sender, eventargs e)         {             gridview1.prerender += new eventhandler(gridview1_prerender);         }         protected void gridview1_prerender(object sender, eventargs e)         {            if (gridview1.rows.count > 0)            {              //forces grid render thead/th elements               gridview1.useaccessibleheader = true;               gridview1.headerrow.tablesection = tablerowsection.tableheader;            }         }     } } 

i getting error of gridview 1 not exist in current context. not sure why happening. insight appreciated.

you appear missing page declaration @ top of web form.

you should have this, wire front , ends. tells design view supporting class file is.

<%@ page language="c#" autoeventwireup="true" codefile="glossary.aspx.cs" inherits="glossary" %> 

if "may" need 1 instead - see have namespace in code-behind

<%@ page language="c#" autoeventwireup="true" codefile="glossary.aspx.cs" inherits="home.glossary" %> 

this account error you're seeing .aspx.cs file doesn't know design view without page directive.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -