Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:GridView ID="gridReviewLog" runat="server" AutoGenerateColumns="false" OnRowEditing="gridReviewLog_RowEditing">
        <Columns>
            <asp:TemplateField HeaderText="Employee Name">
                <ItemTemplate>
                    <asp:TextBox ID="txtempname" runat="server" MaxLength="11" Value='<%#DataBinder.Eval(Container.DataItem,"NAME") %>'  Enabled="false"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Employee Role">
                <ItemTemplate>
                    <asp:TextBox ID="txtrole" runat="server" Value='<%#DataBinder.Eval(Container.DataItem,"ROLE") %>' MaxLength="11"  Enabled="false"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Actual Minute">
                <ItemTemplate>
                    <asp:TextBox ID="txtactualMin" runat="server"  Value='<%#DataBinder.Eval(Container.DataItem,"ACTUALMINUTES") %>' MaxLength="11"  Enabled="false"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Revised Minute">
                <ItemTemplate>
                    <asp:TextBox ID="txtrevisedmin" runat="server" AutoPostBack="true" OnTextChanged="txtrevisedmin_TextChanged" MaxLength="11" Value='<%#DataBinder.Eval(Container.DataItem,"REVISEDMINUTES") %>' Enabled="true"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Employee Cost(per hour)">
                <ItemTemplate>
                    <asp:TextBox ID="cost" runat="server" MaxLength="11" Value='<%#DataBinder.Eval(Container.DataItem,"RATE") %>' Enabled="false"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>



i have gridview like this one.And its textchanged event fires multiple times.

XML
protected void txtrevisedmin_TextChanged(object sender, EventArgs e)
        {
            List<GridRevise> GVList = (List<GridRevise>)ViewState["GridviewList"];
            TextBox thisTextBox = (TextBox)sender;
            GridViewRow currentRow = (GridViewRow)thisTextBox.Parent.Parent;
            int rowIndex = 0;
            rowIndex = currentRow.RowIndex;
        }

Thanks you.
Posted
Comments
Sinisa Hajnal 15-Sep-14 8:26am    
Does it fire exact ROW number of times? How do you bind the event handler?
Xavier Nishanth 15-Sep-14 8:30am    
if i have 3 rows in Grid it fires 3 times and each time it shows each row index.
Sinisa Hajnal 15-Sep-14 9:15am    
Then I suggest you find text control in DataGridRowBound event and change its ID so that each ID is unique.

You didn't post how do you bind event handler. Maybe its not ID problem, but simply that you bind row times same event.

Also, why do you need text-changed event server side?
Xavier Nishanth 16-Sep-14 7:01am    
My friend sorry , i dont know much about this. i have one gridview and Some lables out of gridview when i change value in Revised Minute text box i have to do some calculation and replace Employee Rate field and those lables. i need an event that gives me total gridview values row by row with changed revised min values. so i can do calculation and i ll bind again.
Can you help me?
Sinisa Hajnal 16-Sep-14 7:46am    
Did you try what I mentioned above? Changing textbox ID in DataGridRowBound event? I cannot reach through and change it for you, I can just advise.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900