This is a migrated thread and some comments may be shown as answers.

[Solved] GRID Key pressed detail update

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josef
Top achievements
Rank 1
Josef asked on 21 May 2009, 10:51 AM
Hi, i wrote simple program like this http://demos.telerik.com/aspnet-ajax/ajax/examples/manager/usercontrol/defaultcs.aspx

If i click on the row in grid everithing  is ok - detailview update by id from row.

But i need to upgrade it - the same behavior, but with the keyboard. If i press key down(or up) i need to update detailview with id from selected row.


Thank for yours help.

Josef

MainForm.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainForm.aspx.cs" Inherits="StartProject.MainForm" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
</head> 
<body> 
    <form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager" runat="server"
    </asp:ScriptManager> 
 
    <script type="text/javascript"
        function openWin() { 
            var oWnd = radopen("EditForm.aspx", "EditWindow"); 
        } 
 
   
     
    </script> 
 <telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server"
            <ajaxsettings> 
                <telerik:AjaxSetting AjaxControlID="RadGrid1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                        <telerik:AjaxUpdatedControl ControlID="DetailsView1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                 
            </ajaxsettings> 
        </telerik:RadAjaxManagerProxy> 
     
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource"  
        GridLines"None" width="55%" AllowPaging="True" AllowSorting="True"  
        AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" Skin="Black" 
        OnPreRender="RadGrid1_PreRender" > 
        <ClientSettings EnablePostBackOnRowClick="true" AllowKeyboardNavigation="true" > 
                <Selecting AllowRowSelect="True" />                
        </ClientSettings> 
        <mastertableview datasourceid="SqlDataSource" AutoGenerateColumns="False"  
                    DataKeyNames="dbID"  
                    ClientDataKeyNames="dbID" 
                    Width="100%" 
                    CommandItemDisplay="Bottom"  
                    PageSize="50"
            <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
 
            <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
            <Columns> 
                 <telerik:GridBoundColumn  
                            DataField="dbID"   
                            HeaderText="dbID" 
                            ReadOnly="True"  
                            SortExpression="dbID"  
                            UniqueName="dbID" DataType="System.Int32"
                        </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn  
                            UniqueName="dbJmeno" 
                            DataField="dbJmeno"  
                     HeaderText="dbJmeno"  
                     SortExpression="dbJmeno"
                </telerik:GridBoundColumn> 
                 <telerik:GridBoundColumn  
                 DataField="dbPrijmeni"  
                 HeaderText="dbPrijmeni"  
                     SortExpression="dbPrijmeni"  
                     UniqueName="dbPrijmeni"
                 </telerik:GridBoundColumn> 
                 <telerik:GridBoundColumn  
                 DataField="dbStatus"  
                 DataType="System.Int32"  
                     HeaderText="dbStatus"  
                     SortExpression="dbStatus"  
                     UniqueName="dbStatus"
                 </telerik:GridBoundColumn> 
            </Columns> 
        </mastertableview> 
        <clientsettings> 
            <selecting allowrowselect="True" /> 
            <scrolling allowscroll="True" usestaticheaders="True" /> 
        </clientsettings> 
    </telerik:RadGrid> 
    <asp:SqlDataSource ID="SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
         
        SelectCommand="SELECT [dbID], [dbJmeno], [dbPrijmeni], [dbStatus] FROM [tabKlienti]"
    </asp:SqlDataSource> 
    <telerik:RadWindowManager showID="RadWindowManager" runat="server" ShowContentDuringLoad="false" 
        VisibleStatusbar="false" ReloadOnShow="true"
        <windows> 
    <telerik:RadWindow  
                    ID="EditWindow"  
                    Width="285px"  
                    Height="265px" 
                    NavigateUrl="EditForm.aspx"
                </telerik:RadWindow> 
          
    </windows> 
    </telerik:RadWindowManager> 
    <button onclick="openWin(); return false;"
        Open Edit form</button> 
    <br /> 
    <div style="margin-left: 440px"
    </div> 
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"  
        DataSourceID="SqlDataSource1" Height="50px" Width="125px" > 
        <Fields> 
            <asp:BoundField DataField="dbMistoNarozeni" HeaderText="dbMistoNarozeni"  
                SortExpression="dbMistoNarozeni" /> 
            <asp:BoundField DataField="dbOkresNarozeni" HeaderText="dbOkresNarozeni"  
                SortExpression="dbOkresNarozeni" /> 
            <asp:BoundField DataField="dbNarodnost" HeaderText="dbNarodnost"  
                SortExpression="dbNarodnost" /> 
            <asp:BoundField DataField="dbTypDuchodu" HeaderText="dbTypDuchodu"  
                SortExpression="dbTypDuchodu" /> 
            <asp:BoundField DataField="dbPobytNastoupilDatum"  
                HeaderText="dbPobytNastoupilDatum" SortExpression="dbPobytNastoupilDatum" /> 
            <asp:BoundField DataField="dbOPCislo" HeaderText="dbOPCislo"  
                SortExpression="dbOPCislo" /> 
        </Fields> 
    </asp:DetailsView> 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"  
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"  
        SelectCommand="SELECT [dbMistoNarozeni], [dbOkresNarozeni], [dbNarodnost], [dbTypDuchodu], [dbPobytNastoupilDatum], [dbOPCislo] FROM [tabKlienti]  WHERE ([dbID] = @dbID)"
       <SelectParameters> 
                <asp:ControlParameter ControlID="RadGrid1" DefaultValue="1" Name="dbID" 
                    PropertyName="SelectedValue" Type="String" /> 
            </SelectParameters> 
     
     
    </asp:SqlDataSource> 
    </form> 
</body> 
</html> 
 


MainForm.aspx.cz
public partial class MainForm : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
 
        } 
 
 
        protected void RadGrid1_PreRender(object sender, EventArgs e) 
        { 
            RadGrid1.MasterTableView.Focus(); 
        } 
    } 

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 25 May 2009, 02:22 PM
Hello Josef,

In the other thread you have open you can find attached a sample illustrating how to achieve your goal.

I hope this helps.

Best wishes,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Josef
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or