<asp:GridView ID="GVFeedType" runat="server" Style="margin-bottom: 6px" BorderColor="#BDBDBD"
CssClass="center" Width="500px" AutoGenerateColumns="false">
<EmptyDataTemplate>
No Records found</EmptyDataTemplate>
<Columns>
<asp:BoundField HeaderText="SNo" DataField="SNo" ItemStyle-Width="50px" />
<asp:BoundField HeaderText="Feed Type" DataField="FeedType" ItemStyle-Width="200px" />
<asp:TemplateField HeaderText="Rate/Kg" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:TextBox ID="txtrate" runat="server" Width="100px" OnTextChanged="txtrate_TextChanged"
AutoPostBack="true" />
<asp:RequiredFieldValidator ID="RFVrecdate1" runat="server" ControlToValidate="txtrate"
Display="None" ErrorMessage="Must Enter Rate" ValidationGroup="duereport"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Rate/50 Kg" ItemStyle-Width="80px">
<ItemTemplate>
<asp:Label ID="lbl50kg" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我试过这段代码..
protected void txtrate_TextChanged(object sender, EventArgs e)
{
GridViewRow currentRow = (GridViewRow)(sender as TextBox).Parent.Parent;
float rate = 0;
float kgrate50 = 50;
rate = Convert.ToSingle((sender as TextBox).Text.Trim());
kgrate50 = rate * kgrate50;
(currentRow.Cells[3].FindControl("lbl50kg") as Label).Text = kgrate50.ToString();
GVFeedType.Rows[currentRow.RowIndex + 1].Cells[2].FindControl("txtrate").Focus();
}
此代码没问题,Tab不工作... 我有一个网格视图控件中的文本框,当我输入一些像2,3,4 ..然后它乘以50 ...它显示输出在标签控制..其中标签也在gridview ..如何可以我解决了..请帮帮我......
答案 0 :(得分:0)
我会将CSs类添加到文本框
<asp:TextBox ID="txtrate" runat="server" CssClass="TextBoxToHandle" Width="100px" OnTextChanged="txtrate_TextChanged"
AutoPostBack="true" />
由于使用tab throw focusout事件,您需要订阅它
$(function(){
$(".TextBoxToHandle").focusout(function(){
//Do your code here this would be element which you focus left
});
})