Solved

Getting Compilation Error

Posted on 2016-09-16
3
45 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
Comment Utility
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
Comment Utility
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
Comment Utility
Miguel, Thanks for your help!!!!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

11 Experts available now in Live!

Get 1:1 Help Now