I am using a Devexpress 9 gridview which is bound to a datasource.
I have 3 columns shown below and say 10 row are generated after databinding.
<dxwgv:GridViewDataTextColumn Caption="New Rate" FieldName="Rate2" VisibleIndex="1">
<DataItemTemplate>
<dxe:ASPxTextBox ID="t_newrate" ClientInstanceName="txt1" runat="server" Width="50px">
<ClientSideEvents KeyPress="function(s, e) {
if(event.keyCode == 13)
{
txt2.Focus();
}}" />
</dxe:ASPxTextBox>
</DataItemTemplate>
<HeaderStyle Font-Bold="True" />
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn Caption="New Firm Rate" FieldName="Firm_Rate2" VisibleIndex="2">
<DataItemTemplate>
<dxe:ASPxTextBox ID="t_newfirmrate" runat="server" Width="50px" ClientInstanceName="txt2">
</dxe:ASPxTextBox>
</DataItemTemplate>
<HeaderStyle Font-Bold="True" />
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn Caption="Item_Id" FieldName="Item_Id" VisibleIndex="3">
<HeaderStyle Font-Bold="True" />
</dxwgv:GridViewDataTextColumn>
When I press enter in the first textbox it focus to the next textbox but to the textbox present in the last row. Why isn't it focusing the text box in the same row?
Any other way to approach this??
It is happened by the fact that all ASPxTextBoxes in all DataRows have the same ClientInstanceName – “txt2”.
It is necessary to guarantee the unique ClientInstanceName for each ASPxTextBox inside “Firm_Rate2” column’s DataItemTemplate.
Review the E2284 Code Central example to learn more on how to implement pair of dependent controls inside DataItemTemplates.