Dim i As Integer
            For i = 0 To 6
                e.Row.TabIndex = -1
                CType(e.Row.FindControl("H" & i), TextBox).Attributes.Add("onfocus", "javascript:SimpleTEOnFocus(this)") ' SQ 10/31/2006 SP5
                CType(e.Row.FindControl("H" & i), TextBox).Attributes.Add("onblur", "javascript:SimpleTEOnBlur(this)") ' SQ 10/31/2006 SP5
                CType(e.Row.FindControl("H" & i), TextBox).Attributes.Add("onkeyup", "javascript:keyGridPressed('gridTESimple',this.id,event);SimpleTEHrsOnKeyUp(this,event)") 'AM 12/22/09 Modified
                CType(e.Row.FindControl("H" & i), TextBox).Attributes.Add("onkeypress", "javascript:return NumericOnly(event);")
                CType(e.Row.FindControl("H" & i), TextBox).Attributes.Add("onchange", "javascript:SimpleTEOnChange(this)")
  Next



'HTML CODE


 <div>
        <asp:GridView ID="gridTESimple" runat="server" TabIndex="0" Height="119px" Style="left: 2px; position: absolute;
            top: 154px; z-index: 100;" Width="800px" AutoGenerateColumns="False" ShowFooter="True" Font-Names="Arial" Font-Size="8pt" PageSize="5">
            <Columns>
 <asp:TemplateField HeaderText="Sun">
                    <HeaderStyle Width="45px" ForeColor="Firebrick" BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <ItemTemplate>
                        <asp:TextBox ID="H0" runat="server" CssClass="BQGridTextBoxCenter" Width="40px" Text='<%# Eval("H0") %>'></asp:TextBox>
                    </ItemTemplate>
                    <ItemStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <FooterStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Mon">
                    <HeaderStyle Width="45px" BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <ItemTemplate>
                        <asp:TextBox ID="H1" runat="server" CssClass="BQGridTextBoxCenter" Width="40px" Text='<%# Eval("H1") %>'></asp:TextBox>
                    </ItemTemplate>
                    <ItemStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <FooterStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Tue">
                    <HeaderStyle Width="45px" BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <ItemTemplate>
                        <asp:TextBox ID="H2" runat="server" CssClass="BQGridTextBoxCenter" Width="40px" Text='<%# Eval("H2") %>'></asp:TextBox>
                        
                        
                    </ItemTemplate>
                    <ItemStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <FooterStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Wed">
                    <HeaderStyle Width="45px" BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <ItemTemplate>
                        <asp:TextBox ID="H3" runat="server" CssClass="BQGridTextBoxCenter" Width="40px" Text='<%# Eval("H3") %>'></asp:TextBox>
                       
                    </ItemTemplate>
                    <ItemStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <FooterStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Thur">
                    <HeaderStyle Width="45px" BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <ItemTemplate>
                        <asp:TextBox ID="H4" runat="server" CssClass="BQGridTextBoxCenter" Width="40px" Text='<%# Eval("H4") %>'></asp:TextBox>
                        
                    </ItemTemplate>
                    <ItemStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <FooterStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Fri">
                    <HeaderStyle Width="45px" BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <ItemTemplate>
                        <asp:TextBox ID="H5" runat="server" CssClass="BQGridTextBoxCenter" Width="40px" Text='<%# Eval("H5") %>'></asp:TextBox>
                        
                    </ItemTemplate>
                    <ItemStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <FooterStyle BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Sat">
                    <HeaderStyle Width="45px" ForeColor="Firebrick" BorderColor="Wheat" BorderStyle="Solid" BorderWidth="1px" />
                    <ItemTemplate>
                        <asp:TextBox ID="H6" runat="server" CssClass="BQGridTextBoxCenter" Width="40px" Text='<%# Eval("H6") %>'></asp:TextBox>
                        
                    </ItemTemplate>

 </Columns>
  </asp:GridView>



'javascript



function keyGridPressed(GridName,GridCell,e)
{
  var tblGrid = document.getElementById(GridName);
    var rowcount = tblGrid.rows.length;
    var TBID = document.getElementById(GridCell);
       
       var Key; 

        if(e.keyCode > 0) 

        { 

            Key = e.keyCode; 

        } 

        else if(typeof(e.charCode) != "undefined") 

        { 

            Key = e.charCode; 

        } 
        alert(tblGrid.id);
        alert("You pressed : " + Key); 

  
      if (Key == 37 || Key == 38 || 
         Key == 39 || Key == 40){
       for (Index=1;Index<rowcount;Index++){

         for (childIndex=0;childIndex < 
              tblGrid.rows[Index].cells.length; childIndex++){    
           if (tblGrid.rows[Index].cells[childIndex].children[0] != null){
             if (tblGrid.rows[Index].cells[childIndex].children[0].id == TBID.id){
                    
               if (Key == 40){
                 if (tblGrid.rows[Index + 1].cells[
                     childIndex].children[0] != null){
                   if (tblGrid.rows[Index + 1].cells[
                       childIndex].children[0].type == 'text'){
                            
                     //downvalue
                     tblGrid.rows[Index + 1].cells[
                             childIndex].children[0].focus(); 
                     return false;    
                   }
                 } 
               }
              }
           }
         }
       }
     }
   }
Please help me solve this........this is not a problem regarding e.keycode or e.which or something else.i am recieving perfect codes in "Mozilla Firefox" ,but i am getting an error in error console saying
"tblGrid.rows[Index].cells[childIndex].children[0] not defined "...evrything lies in here.....i also read a forum writing "its all about cell indexes not getting uniquely identified"....polease can anyone help me.....

99% is problem somewhere in the javascript part. Install Firebug plugin, trace the line where error occurs. IE is much more tollerant to improper constructions e.g. () x [] etc.

the prob with tblGrid.rows[Index].cells[childIndex].children[0] is :

rows property is not supported by mozilla.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.