Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Close window without confirm (I.E only) window.opener=null; window.open('','_self'); window.close(); focus on validating function focusOnInvalidControl() {     for (var i = 0; i < Page_Validators.length; i++) {         if (!Page_Validators[i].isvalid) {     ...
Blog Archive
Stats
GridView mischief
There was a requirement for append a row after every data row in GridView. In begining I tried to get current row and want to append a new row after it. But it's hard to achieve this. And finally, I found a mischief way to append a new row and think : WHY CAN I HIT UPON TO GET IT?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewMischief.aspx.cs"
    Inherits="GridViewMischief" %>

<!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>GridView mischief</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="mischiefGridView" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            DataKeyNames="ID" DataSourceID="mischief" CellPadding="4" ForeColor="#333333"
            GridLines="None" BorderWidth="0" Width="100%">
            <RowStyle BackColor="#EFF3FB" HorizontalAlign="Center" />
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="編號" InsertVisible="False" ReadOnly="True"
                    SortExpression="ID" />
                <asp:BoundField DataField="UniqueID" HeaderText="序號" SortExpression="UniqueID" />
                <asp:BoundField DataField="Price" HeaderText="價格" SortExpression="Price" />
                <asp:BoundField DataField="Amount" HeaderText="數量" SortExpression="Amount" />
                <asp:BoundField DataField="CreateDate" HeaderText="日期" SortExpression="CreateDate" />
                <asp:CommandField ShowDeleteButton="True" HeaderText="刪除" />
                <asp:TemplateField ShowHeader="False" HeaderText="編輯">
                    <EditItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                            Text="更新"></asp:LinkButton>
                        &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                            Text="取消"></asp:LinkButton>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                            Text="編輯"></asp:LinkButton>
                        </td></tr>
                        <tr>
                            <td colspan="7">
                                <hr />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="#DCDCDC" />
        </asp:GridView>
        <asp:SqlDataSource ID="mischief" runat="server" ConnectionString="<%$ ConnectionStrings:brucedbConnectionString %>"
            SelectCommand="SELECT * FROM [GV]" DeleteCommand="DELETE FROM [GV] WHERE [ID] = @ID"
            InsertCommand="INSERT INTO [GV] ([UniqueID], [Price], [Amount], [CreateDate]) VALUES (@UniqueID, @Price, @Amount, @CreateDate)"
            UpdateCommand="UPDATE [GV] SET [UniqueID] = @UniqueID, [Price] = @Price, [Amount] = @Amount, [CreateDate] = @CreateDate WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="UniqueID" Type="String" />
                <asp:Parameter Name="Price" Type="Int32" />
                <asp:Parameter Name="Amount" Type="Int32" />
                <asp:Parameter DbType="Date" Name="CreateDate" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="UniqueID" Type="String" />
                <asp:Parameter Name="Price" Type="Int32" />
                <asp:Parameter Name="Amount" Type="Int32" />
                <asp:Parameter DbType="Date" Name="CreateDate" />
            </InsertParameters>
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>