摘要

在同一頁面上以 GridView 配合 FormView 來完成資料的「新增/修改/刪除」,在這個範例中有下列二個特點。

1. GridView 及 FormView 繫結同一個 SqlDataSource 控制項。

2. FormView 只使用 EditItemTemplate,同時來做新增及修改的動作。

範例程式碼: GridView1.rar

畫面配置

此範例使用 Northwind 資料庫的 Employees 資料表當作資料來源,在頁面上放置 SqlDataSource、GridView、FormView,而 GridView 及 FormView 繫結至同一個 SqlDataSource 控制項。
GridView 的部分,啟用分頁模式,每頁設為 5 筆,並將 CommandField 轉為 TemplateField,然後在 HeaderTemplate 部分加入一個「新增」鈕。
FormView 的部分在瀏覽模式為隱藏,設定屬性 Visible="False"。執行新增及編輯時只會使用到 EditItemTemplate,故只保留 EditItemTemplate 的內容,然後設定屬性 DefaultMode="Edit"。

image

aspx 程式碼如下

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!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 style="text-align: center">
        <strong><span style="color: #3333ff">GridView+FormView 示範資料 新增/修改/刪除<br />
        </span></strong>
        <br />
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            CellPadding="4" DataKeyNames="EmployeeID" DataSourceID="SqlDataSource1" EmptyDataText="沒有資料錄可顯示。"
            ForeColor="#333333" GridLines="None" PageSize="5">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:TemplateField ShowHeader="False">
                    <HeaderTemplate>
                        <asp:Button ID="btnInsert" runat="server" CausesValidation="False" CommandName="Insert"
                            Text="新增"></asp:Button>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Button ID="btnEdit" runat="server" CausesValidation="False" CommandName="Edit"
                            Text="編輯"></asp:Button>
                        <asp:Button ID="btnDelete" runat="server" CausesValidation="False" CommandName="Delete"
                            Text="刪除"></asp:Button>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" InsertVisible="False"
                    ReadOnly="True" SortExpression="EmployeeID" />
                <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
                <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
            </Columns>
            <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="White" />
        </asp:GridView>
        <asp:FormView ID="FormView1" runat="server" CellPadding="4" DataKeyNames="EmployeeID"
            DataSourceID="SqlDataSource1" DefaultMode="Edit" ForeColor="#333333" Visible="False">
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <EditItemTemplate>
                <table style="width: 400px">
                    <tr>
                        <td style="width: 100px; text-align: left">
                            EmployeeID</td>
                        <td style="width: 392px; text-align: left">
                            <asp:Label ID="EmployeeIDLabel1" runat="server" Text='<%# Eval("EmployeeID") %>'></asp:Label>
                            <asp:TextBox ID="txtEmployeeID" runat="server" Text='<%# Bind("EmployeeID") %>'></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td style="width: 100px; text-align: left">
                            LastName</td>
                        <td style="width: 392px; text-align: left">
                            <asp:TextBox ID="txtLastName" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td style="width: 100px; text-align: left">
                            FirstName</td>
                        <td style="width: 392px; text-align: left">
                            <asp:TextBox ID="txtFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td style="width: 100px; text-align: left">
                            Title</td>
                        <td style="width: 392px; text-align: left">
                            <asp:TextBox ID="txtTitle" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox></td>
                    </tr>
                </table>
                <br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="False" CommandName="Insert"
                    Text="新增"></asp:LinkButton>
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                    Text="更新"></asp:LinkButton>
                <asp:LinkButton ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="取消"></asp:LinkButton>
            </EditItemTemplate>
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString1 %>"
            DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @original_EmployeeID" InsertCommand="INSERT INTO [Employees] ([LastName], [FirstName], [Title]) VALUES (@LastName, @FirstName, @Title)"
            ProviderName="<%$ ConnectionStrings:NorthwindConnectionString1.ProviderName %>"
            SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [Title] FROM [Employees]"
            UpdateCommand="UPDATE [Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [Title] = @Title WHERE [EmployeeID] = @original_EmployeeID" OldValuesParameterFormatString="original_{0}">
            <DeleteParameters>
                <asp:Parameter Name="original_EmployeeID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="LastName" Type="String" />
                <asp:Parameter Name="FirstName" Type="String" />
                <asp:Parameter Name="Title" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="LastName" Type="String" />
                <asp:Parameter Name="FirstName" Type="String" />
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="original_EmployeeID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <br />
    
    </div>
    </form>
</body>
</html>

 

程式碼說明

GridView 的 CommandField 因為切換為 TemplateField,所以在 RowDataBound 事件中,需要去設定「編輯」鈕的 CommandArgument 屬性值為 RowIndex,GridView 的編輯動作才能正常執行。

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        Dim oButton As Button

        If e.Row.RowType = DataControlRowType.DataRow Then
            '設定編輯鈕的 CommandArgument
            oButton = CType(e.Row.Cells(0).FindControl("btnEdit"), Button)
            oButton.CommandArgument = e.Row.RowIndex.ToString
        End If
    End Sub

程式執行時預設為瀏覽模式,故只有顯示 GridView,而 FormView 預設是隱藏。當 GridView 按下新增及編輯時,需要將 GirdView 隱藏,將 FormView 顯示。所以在 GridView 的 RowCommand 事件中撰寫如下程式碼。
執行「編輯」時,以 GetEditIndex 函式是取得 FormView 對應的編輯列索引,設定給 FormView.PageIndex,並將 FormView 切換為編輯模式。
執行「新增」鈕,將 FormView.InsertItemTemplate 設為 FormView.EddiItemTemplate,即新增及編輯都使用同一個 Template,並將 FormView 切換為新增模式。

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        Dim iEditIndex As Integer

        Select Case e.CommandName.ToUpper
            Case "Edit".ToUpper '編輯模式
                iEditIndex = GetEditIndex(CType(sender, GridView), CInt(e.CommandArgument))
                FormView1.PageIndex = iEditIndex
                FormView1.ChangeMode(FormViewMode.Edit) 'FormView 切換為編輯模式
                FormView1.Visible = True  'FormView 顯示
                GridView1.Visible = False 'GridView 隱藏

            Case "Insert".ToUpper '新增模式
                '因為只有使用 EditItemTemplate,故將 InsertItemTemplate 設為 EditItemTemplate
                FormView1.InsertItemTemplate = FormView1.EditItemTemplate
                FormView1.ChangeMode(FormViewMode.Insert) 'FormView 切換為新增模式
                FormView1.Visible = True  'FormView 顯示
                GridView1.Visible = False 'GridView 隱藏
        End Select
    End Sub

    ''' <summary>
    ''' 取得編輯列索引。
    ''' </summary>
    ''' <param name="GridView">GridView 控制項。</param>
    ''' <param name="RowIndex">GridView 的資料列索引。</param>
    Private Function GetEditIndex(ByVal GridView As GridView, ByVal RowIndex As Integer) As Integer
        Dim iEditIndex As Integer

        If GridView.AllowPaging Then
            'GridView 有分頁時,要把考慮目前的頁數及每頁筆數
            iEditIndex = (GridView.PageIndex) * GridView.PageSize + RowIndex
        Else
            'GridView 無分頁時,直接使用 e.NewSelectedIndex
            iEditIndex = RowIndex
        End If
        Return iEditIndex
    End Function

在 FormView 中因為只使用 EddiItemTemplate 來處理「新增」及「編輯」模式,做需要置放「新增」、「更新」、「取消」三個按鈕。
在「新增」模式顯示「新增」鈕與「取消」鈕,以及顯示 EmployeeID 欄位的 TextBox。
在「編輯」模式顯示「更新」鈕與「取消」鈕。EmployeeID 欄位為唯讀,故隱藏 EmployeeID 欄位的 TextBox。
針對以上的處理動作,在 FormView 的 PreRender 事件中撰寫如下程式碼來處理 FormView 子控制項的顯示及隱藏狀態。

    Protected Sub FormView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.PreRender
        Dim oFormView As FormView
        Dim oLinkButton As LinkButton
        Dim oTextBox As TextBox

        oFormView = CType(sender, FormView)
        If Not oFormView.Visible Then Exit Sub

        Select Case oFormView.CurrentMode
            Case FormViewMode.Edit '編輯模式
                '隱藏新增鈕
                oLinkButton = oFormView.FindControl("InsertButton")
                oLinkButton.Visible = False
                '顯示更新鈕
                oLinkButton = oFormView.FindControl("UpdateButton")
                oLinkButton.Visible = True
                '顯示 EmployeeID 的 TextBox
                oTextBox = oFormView.FindControl("txtEmployeeID")
                oTextBox.Visible = False
            Case FormViewMode.Insert
                '顯示新增鈕
                oLinkButton = oFormView.FindControl("InsertButton")
                oLinkButton.Visible = True
                '隱藏更新鈕
                oLinkButton = oFormView.FindControl("UpdateButton")
                oLinkButton.Visible = False
                '顯示 EmployeeID 的 TextBox
                oTextBox = oFormView.FindControl("txtEmployeeID")
                oTextBox.Visible = True
        End Select
    End Sub

當 FormView 執行「新增」、「更新」、「取消」鈕的動作後,需要切換回瀏覽模式,即將 FormView 隱藏,而顯示 GridView,相關程式碼如下。

    ''' <summary>
    ''' 切換為瀏覽模式。
    ''' </summary>
    Private Sub ChangeViewMode()
        FormView1.Visible = False
        GridView1.Visible = True
        GridView1.EditIndex = -1
    End Sub

    Protected Sub FormView1_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewCommandEventArgs) Handles FormView1.ItemCommand
        If e.CommandName.ToUpper = "Cancel".ToUpper Then
            '取消後,切換為瀏覽模式
            ChangeViewMode()
        End If
    End Sub

    Protected Sub FormView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs) Handles FormView1.ItemInserted
        '新增後,切換為瀏覽模式
        ChangeViewMode()
    End Sub

    Protected Sub FormView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs) Handles FormView1.ItemUpdated
        '更新後,切換為瀏覽模式
        ChangeViewMode()
    End Sub

 

執行程式

執行程式預設為瀏覽模式

image 

按下 GridView 的「新增」鈕時,即會切換到 FormView 的新增模式。

image

按鈕 GridView 的「編輯」鈕時,即會切換到 FormView 的編輯模式。

image

ASP.NET 魔法學院


DotBlogs Tags: FormView GridView

Feedback

  • 佩妮 ~ 2008/9/16 上午 09:36 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    感謝大大您的分享...

    因為目前佩妮也在做新增員工表的動作...

    有您的範例...可以參考...減少了不少的程式碼撰寫...

    目前佩妮參考這個範例...試作...

    有兩地方有問題...不知是大大...想留個參考人的考驗還是...

    第一個是...假若要切換gridview的新增與編輯...只要按完新增後...再按編輯...就會出現此錯誤訊息...『http://picasaweb.google.com.tw/apple1588/uwJXo#5246426452052892402』

    第二個是...於新增一筆新的資料...因原指令裡沒有加入employeeid這個欄位...所以也會出現錯誤...

    所以想要和大大您確認一下...謝謝您...

    佩妮

  • jeff 2008/9/16 下午 08:00 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    to 佩妮 ~ :
    第一個問題:
    我知道有這個錯誤,我有改掉此文的進階篇「GridView+FormView 示範資料 新增/修改/刪除(進階篇:伺服器控制項)」中伺服器控制項解決這個問題,我再將此伺服器控制項修改一下上傳。

    第二個問題:
    employeeid 欄位是主索引欄位,你要使用你真正的主索引欄位來取代。

  • 佩妮 ~ 2008/9/18 下午 03:39 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    感謝Jeff大大的分享...
    謝謝您...

  • 佩妮 ~ 2008/9/18 下午 03:45 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    Jeff 大大您好:

    想再向您請教...因為gridview是抓資料庫裡的值...

    若目前...資料庫裡沒有任何記錄...

    即時有新增的功能...也會因為目前資料庫裡沒有記錄...

    而無法顯示對嗎...

    麻煩大大您指點...謝謝...

  • 佩妮 ~ 2008/9/18 下午 05:31 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    Jeff 大大您好:

    謝謝您...

    我有看到您分享的這一篇...

    http://www.dotblogs.com.tw/jeff377/archive/2008/05/22/4105.aspx

  • jill 2008/10/14 下午 03:49 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    你好~
    我套用程式碼,但出現
    無法將型別 'System.Web.UI.WebControls.LinkButton' 的物件轉換為型別 'System.Web.UI.WebControls.Button'。

    行 99: oButton = CType(e.Row.Cells(0).FindControl("btnEdit"), Button)

    這行出現問題,想請問我程式哪邊出了問題?

  • jeff377 2008/10/14 下午 04:15 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    to jill :
    你的 GridView 中的按鈕是使用 LinkButton,這個案例是使用 Button,你只要修改為你按鈕的型別即可。

  • 飯糰 2008/10/22 上午 10:15 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    東西都跑出來了 但是按鈕都不會有變化呢

    幫幫忙

  • jeff377 2008/10/22 上午 11:04 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    to 飯糰 :
    不太明白你的問題,什麼是「東西都跑出來了,按鈕不會有變化」 ....

  • RICE 2008/10/22 下午 01:40 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    在 FormView 中因為只使用 EddiItemTemplate 來處理「新增」及「編輯」模式,做需要置放「新增」、「更新」、「取消」三個按鈕。
    在「新增」模式顯示「新增」鈕與「取消」鈕,以及顯示 EmployeeID 欄位的 TextBox。
    在「編輯」模式顯示「更新」鈕與「取消」鈕。EmployeeID 欄位為唯讀,故隱藏 EmployeeID 欄位的 TextBox。
    針對以上的處理動作,在 FormView 的 PreRender 事件中撰寫如下程式碼來處理 FormView 子控制項的顯示及隱藏狀態。

    這一段我不太懂 我的意思 都照你所說ㄉ做但是 都無法RUN 是不是哪些紐沒有設定它ㄉ屬性還是怎樣ㄉ 謝謝

  • RICE 2008/10/22 下午 01:48 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    並未將物件參考設定為物件的執行個體

    olabel.Visible = False

  • RICE 2008/10/22 下午 02:29 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    執行「編輯」時,以 GetEditIndex 函式是取得 FormView 對應的編輯列索引,設定給 FormView.PageIndex,並將 FormView 切換為編輯模式。
    執行「新增」鈕,將 FormView.InsertItemTemplate 設為 FormView.EddiItemTemplate,即新增及編輯都使用同一個 Template,並將 FormView 切換為新增模式。


    這一段話要怎樣做

  • RICE 2008/10/22 下午 03:32 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    無法插入 NULL 值到資料行 'admin_no',資料表 'ATTECA.dbo.admin'; 資料行不得有 Null。INSERT 失敗。
    陳述式已經結束。


    因為我NO是自動編號

    那要怎處理才可以寫入 謝謝

  • rice 2008/10/23 上午 10:54 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    已經可以了 但是編輯的時候為什麼不可以重複編輯

    但是只要你去下一個編輯完時 再回去編輯 就可以ㄌ

    很奇怪

  • LC 2008/10/27 上午 03:15 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    他寫說
    oButton.CommandArgument = e.Row.RowIndex.ToString

    錯誤

    使用者程式碼未處理NullReferenceException

    請問是啥意思??

  • jeff377 2008/10/28 下午 01:37 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    你可以參考下面的文章,其中已經解決掉這個範例的所有問題,而且是使用伺服器控制項完全不用任何程式碼。

    [ASP.NET 控制項實作 Day27] 控制項依 FormView CurrentMode 自行設定狀態

  • ting 2009/1/12 下午 02:20 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    請問
    GridView 及 FormView 只能繫結同一個 SqlDataSource 控制項,才能執行以下功能嗎?

  • jeff377 2009/1/15 上午 09:29 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    to ting :
    這個範例一定要繫結同一個 SqlDataSource,就是為了簡化程式才直接繫結同一個 SqlDataSource,沒必要使用二個 SqlDataSource 來使程式複雜化又沒效能。

  • kelly 2009/4/13 下午 11:27 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    你好
    我按照以上的方法做
    可以插入 可以修改 可是就沒辦法刪除

    另外想請問一個問題 我在insert的時候 把控制項換成dropdownlist 可是卻沒辦法抓到dropdownlist裡面的值

  • jac ky 2009/5/5 上午 11:48 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    您好:

    請問一下.
    按gridview的新增以後.
    切換到 FormView 的編輯模式會另外開一個視窗.
    而不是在原本的視窗.
    這樣是什麼問題呢?
    感謝~~~

  • sorting 2009/9/2 下午 02:00 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除


    請問在這個方法下,如果用了gridview的allowsorting,抓到的rowindex還是正常的嗎?

  • Benson 2009/9/26 下午 05:05 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    Jeff你好
    這範例十分受用,先謝謝你
    有些地方想請教一下
    sqldatasource裡面設的參數,是不是只能跟sql server聯動
    我現在不太懂那些sql command所需要的參數是從哪裡抓到的
    只看到你在sqldatasource裡面有放參數
    但由於我的database是my sql,我將你的範例連線的資料庫改成my sql後
    動作還是正常,只是資料都沒有更新或是新增進資料庫

  • jeff 2009/9/27 上午 11:17 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    to Benson :
    新增或修改是要看 SqlDataSouce 的 InsertCommand 及 UpdateCommand 的語法是否正確,語法正確的話才有辨法對資料庫做相關異動。

  • jeff 2009/9/27 上午 11:28 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    to sorting :
    GridView 及 FormView 的連動已有考慮到分頁問題。

  • Benson 2009/10/2 下午 06:39 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    Jeff你好
    之前那問題是我自己沒搞清楚
    用oledb的話,參數傳遞是@
    用odbc的話,參數則要用?來傳
    但目前我新增的功能正常,更新則沒有動作也沒有錯誤
    我的sql語法有下where這條件判斷
    反覆看來看去跟你提供的程式碼也一樣,實在不懂
    並且只有單一用gridview時,更新可以運作
    一旦跟formview連動,就失效
    有沒有什麼其他該注意的地方
    謝謝

  • Benson 2009/10/5 下午 03:50 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    Jeff不好意思
    那個問題我自己找到答案了
    以Formview在做Update動作時
    只要有放在Formview裡的欄位,都要做更新
    也就是在SqlDataSource中,都要設參數,除了Primary Key
    以你的例子來說,只要我拿掉LastName, FirstName或Title其中一個欄位不更新
    Update就不會有動作
    這是Formview的限制嗎?

  • linadan 2009/10/15 下午 06:45 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    Jeff您好:
    請問Formview按新增後,回到gridview時,再按新增,Formview仍會有上次的輸入值?該如何解決,謝謝您

  • linadan 2009/10/17 下午 03:18 回覆

    # re: GridView+FormView 示範資料 新增/修改/刪除

    Jeff您好:
    對不起,也許描述不夠詳細,依您的作法,只增加了ajax的二個updatepanel
    1.若不隱藏gridview及formview,formview新增後欄位自會清空,gridview會產生新增的那筆,但
    2.若依您作法隱藏gridview或formview,則Formview按新增後,會隱藏並回到gridview時,再按新增時會隱藏gridview,這時Formview仍會有上次的輸入值,請問怎麼會有這種情形?試了好多種方法,都無法去除formview的殘留資料,煩請大大協助一下,謝謝

標題 *
名稱 *
Email (將不會被顯示)
Url
回應
登入後使用進階評論
Please add 7 and 3 and type the answer here: