views:

34

answers:

2

Hello.

I have the following gridview that is inside an updatepanel:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Button ID="ButtonAdd" runat="server" OnClick="ButtonAdd_Click" Text="Novo Artigo" />
        <asp:GridView ID="Dados" runat="server" AutoGenerateColumns="False" CssClass="Grid">
            <Columns>
                <asp:TemplateField HeaderText="Artigo">
                    <ItemTemplate>
                        <asp:TextBox ID="Artigo" runat="server"></asp:TextBox>
                        <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
                        TargetControlID="Artigo"
                        PopupControlID="PanelArtigos"
                        >
                        </asp:ModalPopupExtender>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Descrição">
                    <ItemTemplate>
                        <asp:TextBox ID="Descricao" runat="server" Width="300px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="IVA">
                    <ItemTemplate>
                        <asp:TextBox ID="IVA" runat="server" Width="40px" Enabled="false"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Pr. Unit.">
                    <ItemTemplate>
                        <asp:TextBox ID="PU" runat="server" Width="50px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="% Desc.">
                    <ItemTemplate>
                        <asp:TextBox ID="Desconto" runat="server"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="UN">
                    <ItemTemplate>
                        <asp:TextBox ID="UN" runat="server" Width="50px" Enabled="false"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Quant.">
                    <ItemTemplate>
                        <asp:TextBox ID="Quantidade" runat="server" Width="50px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Total Liquido">
                    <ItemTemplate>
                        <asp:TextBox ID="TotalLiquido" runat="server" Enabled="false"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="RemoveArtigo" runat="server" OnClick="RemoveArtigo_Click">Remover
                        </asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle Font-Size="Small" />
            <RowStyle Font-Size="Small" CssClass="grid" />
        </asp:GridView>
    </ContentTemplate>
</asp:UpdatePanel>

As you can see, i have some textbox's.

When i change a value in a textbox, for example, the Desconto value, and leave that textbox, i want that the row where i am to be updated, using the new value present in the textbox. It's like a TextChanged or onBlur, but inside the update panel it's not working.

what is the best way to do it?

I am using VB.NET.

Thank you.

EDIT:

When adding the OnTextChanged="Desconto_TextChanged" i receive this compilation error:

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'Desconto_TextChanged' is not a member of 'ASP.index_aspx'.

Source Error:

Line 204:
Line 205:
Line 206:
Line 207:
Line 208:

Source File: C:\inetpub\wwwroot\Facturas\Facturas\index.aspx Line: 206

+1  A: 

TextBox controls will not initiate a postback by default. you can set AutoPostBack to true for each textbox control.

lincolnk
But which event can i use to ensure that the row is updated when the AutoPostBack is done?
Filipe Costa
+1  A: 

I believe the event you need is TextChanged. Like lincolnk said, you need AutoPostBack set to True for the textbox to fire the postback. Then, inside the event handler, call Dados.DataBind() to reload the GridView's data.

ChessWhiz
When i create the TextChanged event in the Desconto button and try to compile, i receive this error:Compiler Error Message: BC30456: 'Desconto_TextChanged' is not a member of 'ASP.index_aspx'.Is it because of the gridview is inside an update panel? Cannot find it that way?
Filipe Costa
It should still be visible inside the update panel. How are you creating the TextChanged event? It sounds like the event handler is not being set properly.
ChessWhiz