<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<%@ 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">
    <div>
    
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
    
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" 
            AutoGenerateEditColumn="True" CellSpacing="0" GridLines="None" 
            onitemcreated="RadGrid1_ItemCreated" O AllowAutomaticDeletes="True" 
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True">
<MasterTableView autogeneratecolumns="False" datakeynames="ID" 
                datasourceid="SqlDataSource1">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

    <Columns>
        <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" 
            FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True" 
            SortExpression="ID" UniqueName="ID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Title" 
            FilterControlAltText="Filter Title column" HeaderText="Title" 
            SortExpression="Title" UniqueName="Title">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Rating" DataType="System.Decimal" 
            FilterControlAltText="Filter Rating column" HeaderText="Rating" 
            SortExpression="Rating" UniqueName="Rating">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Votes" DataType="System.Int32" 
            FilterControlAltText="Filter Votes column" HeaderText="Votes" 
            SortExpression="Votes" UniqueName="Votes">
        </telerik:GridBoundColumn>
        <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" 
            HeaderText="Rating" UniqueName="TemplateColumn">
            <EditItemTemplate>
                <telerik:RadRating ID="RadRating1" Runat="server" DbValue="0" AutoPostBack="true"
                    Value='<%# Bind("Rating") %>' onrate="RadRating1_Rate">
                </telerik:RadRating>
            </EditItemTemplate>
            <ItemTemplate>
                <telerik:RadRating ID="RadRating2" Runat="server" DbValue="0" AutoPostBack="true"
                    Value='<%# Bind("Rating") %>'>
                </telerik:RadRating>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
    </Columns>

<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>

<FilterMenu EnableImageSprites="False"></FilterMenu>

<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" 
            InsertCommand="INSERT INTO [MovieRatings] ([Title], [Rating], [Votes]) VALUES (@Title, @Rating, @Votes)" 
            SelectCommand="SELECT [ID], [Title], [Rating], [Votes] FROM [MovieRatings]" 
            UpdateCommand="UPDATE [MovieRatings] SET [Title] = @Title, [Rating] = @Rating, [Votes] = @Votes WHERE [ID] = @ID">
           <UpdateParameters>
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="Rating" Type="Decimal" />
                <asp:Parameter Name="Votes" Type="Int32" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="Rating" Type="Decimal" />
                <asp:Parameter Name="Votes" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>
