How to capture event on Text box placed in a GridView?

partha.majumdar

Active member
Joined
Aug 13, 2006
Messages
33
Location
Kolkata
Programming Experience
10+
DEar Sir/Madam,

I have used a GridView in which I have created a TemplateColumn. In the ItemTemplate of the TemplateColumn, I have placed a TextBox. For this TextBox, I have made AutoPostBack as True because I want to capture the moment a value changes in the TextBox. Now, how do I capture this event when the postback happend from this textbox.

Please advice.

Thanks and Regards,
Partha
 
Dear Sir,

I invoked a method from the TextBox for the OnTExtChanged event as follows

<asp:TextBox ID="tbTimeSat" runat="server" Height="20px" Width="53px" MaxLength="2" OnTextChanged="SatTimeChanged"
Text='<%# Bind("Day_Saturday") %>' AutoPostBack="True"></asp:TextBox>

Now I am able to capture the event when the time changes.

However, what I want to do is to display the total of the column in the footer when the value is changed. How can I compute the total for the GridViewColumn and display in the footer?

Please advice.

Thanks and Regards,
Partha
 
Sorry for this question as I have found a way to find the total. I used DataTable.Compute method as follows:

_dtblMain.Compute("Sum(Day_Saturday)", "1=1")

Now the problem is in displaying this value in the footer. I have placed a label control in the footer, but cannot find any method to get to that control.

The definition is as follows:
<asp:TemplateField HeaderText="Day SAT">
<FooterTemplate>
<asp:Label ID="lblTotalSat" runat="server" Text="Label"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:TextBox ID="tbTimeSat" runat="server" Height="20px" Width="53px" MaxLength="2" OnTextChanged="SatTimeChanged"
Text='<%# Bind("Day_Saturday") %>' AutoPostBack="True"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>


Please advice.

Thanks and Regards,
Partha
 
Well I found a way.

CType(gvTimeSheet.FooterRow.Cells(2).FindControl("lblTotal" + lstrDayName), Label).Text = _dtblMain.Compute("Sum(Day" + lstrDayName + ")", "1=1").ToString


Regards,
Partha
 
Back
Top