行单击“仅刷新详细信息视图”而不刷新整页

时间:2014-08-05 17:27:26

标签: asp.net vb.net

我是ASP.NET新手,需要帮助。基本上,我在同一页面上有一个GridView1和DetailsView1。我想要做的是当用户点击该行时,它只会刷新该特定记录的DetailsView1区域。以下代码用于查看DetailsView1区域中的记录,但它也刷新整个页面。如果可能,请提供示例代码。

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="TrackID" ShowFooter="True" 
    AllowPaging="True" PageSize="8"
     SelectedIndex="0" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"

     OnPageIndexChanging="GridView1_SelectedIndexChanging"
     OnPageIndexChanged="GridView1_PageIndexChanged" OnRowDeleted="GridView1_RowDeleted" OnSorted="GridView1_Sorted"
    OnSorting="GridView1_Sorting"

     ShowHeaderWhenEmpty="True" EmptyDataText="No records Found"

     EnableRowClick = "True" Width="100%" AllowSorting="True"                         
>
    /.....  Fields Are Here ...../
</asp:GridView>


<asp:DetailsView AutoGenerateRows="False" DataKeyNames="TrackID" DataSourceID="SqlDataSource2"
    HeaderText="Project Detail" ID="DetailsView1" runat="server" Width="100%" OnItemUpdated="DetailsView1_ItemUpdated" 
        OnItemInserted="DetailsView1_ItemInserted"  OnDataBound="DetailsView1_DataBound"
    validateRequest="false" RowStyle-BackColor="White" OnItemDeleted="SqlDataSource2_ItemDeleted"                    
    >
    /.....  Fields Are Here ...../
</asp:DetailsView> 

代码背后:

Private Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
    If e.Row.RowType = DataControlRowType.DataRow Then

        Dim RowNum As Integer
        RowNum = e.Row.RowIndex

        If RowNum Mod 2 = 1 Then

            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='LightCyan'")

        Else

            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'")

        End If

        e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='LightBlue'")
        e.Row.Attributes("onclick") = Me.Page.ClientScript.GetPostBackClientHyperlink(Me.GridView1, "Select$" & e.Row.RowIndex)
    End If

0 个答案:

没有答案