Solved

Getting Compilation Error

Posted on 2016-09-16
3
51 Views
Last Modified: 2016-09-23
Hi, I am trying to edit/update the gridview without using edit and update buttons. I am not sure how to achieve this yet. I converted the vb code below from c# and got a compilation error. Can someone help? Thank you!


Compilation Error

Compiler Error Message: BC30456: 'GridView1_RowCommand' is not a member of 'ASP.itrequest_aspx'.

Source Error:


Line 32: <asp:LinkButton ID="lnkDummy" runat="server"></asp:LinkButton>
Line 33:
Line 34: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Line 35:             BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px"
Line 36:             CellPadding="4" ForeColor="Black"

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px"
            CellPadding="4" ForeColor="Black"
            GridLines="Vertical" OnRowCreated="GridView1_RowCreated" OnRowCommand="GridView1_RowCommand">
            <RowStyle BackColor="#F7F7DE" />
            <Columns>
                <asp:BoundField DataField="Room" HeaderText="Room" SortExpression="Room" />
                <asp:TemplateField HeaderText="TextBox">
                <ItemTemplate>
                    <asp:TextBox runat="server" ID="txtfocus" AutoPostBack="true"></asp:TextBox>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#CCCC99" />
            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
            <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>


Protected Sub GridView1_RowCreated(sender As Object, e As GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow Then
            If e.Row.FindControl("txtfocus") IsNot Nothing Then
                Dim txtfocus As TextBox = DirectCast(e.Row.FindControl("txtfocus"), TextBox)
                AddHandler txtfocus.TextChanged, New EventHandler(AddressOf txtfocus_TextChanged)
            End If
        End If
    End Sub

    Private Sub txtfocus_TextChanged(sender As Object, e As EventArgs)
        'get current textbox
        Dim txt As TextBox = DirectCast(sender, TextBox)
        'find other controls in the same row
        Dim gvr As GridViewRow = DirectCast(txt.Parent.Parent, GridViewRow)
        Dim txtone As TextBox = DirectCast(gvr.FindControl("txtone"), TextBox)
        'update to database
    End Sub
0
Comment
Question by:HPH Y
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 41802519
Your code behind does not have "GridView1_RowCommand" defined.
One possible solution is to delete OnRowCommand event from aspx file:
Replace:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
             BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" 
             CellPadding="4" ForeColor="Black" 
             GridLines="Vertical" OnRowCreated="GridView1_RowCreated" OnRowCommand="GridView1_RowCommand">

Open in new window

with:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
             BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" 
             CellPadding="4" ForeColor="Black" 
             GridLines="Vertical" OnRowCreated="GridView1_RowCreated">

Open in new window

0
 

Author Comment

by:HPH Y
ID: 41804829
Thanks Miguel! The error is gone. the problem now is when I entered something in the textbox, the DirectCast does not cast any value at all. Any suggestions? Thank you.
0
 

Author Closing Comment

by:HPH Y
ID: 41812316
Miguel, Thanks for your help!!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adjust the position 3 50
Entity Framework 3 48
Syntax error 9 45
SignalR's 'connection.Hub' only returns the Hub on the first page 1 5
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now