ASP.NET 4.6 Gridview / SqlDatasource已损坏 [英] ASP.NET 4.6 Gridview / SqlDatasource Broken

查看:53
本文介绍了ASP.NET 4.6 Gridview / SqlDatasource已损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个人让我感到困惑,但考虑到我已经离开代码大约5年而现在只是被推回去(心甘情愿),这并不难。很多已经改变,但我认为我已经涵盖了所有的基础,但这应该在某条线上工作,但事实并非如此。



它正在努力一点,但我做了一些格式改变,打破了它。尽管倒退虽然改变没有解决突破。帮助!!!



这就是我所拥有的......



简单的gridview除了有几个其中的模板字段用于下拉框和一个复选框(由于我正在处理的格式噩梦,目前已关闭)。 gridview由一个标准的SqlDataSource连接驱动,其中包含为插入,更新和删除而构建的方法。



我已经关注了我在网上发现的例子...我已经在处理程序后面添加了一个代码,用它自己提示进行更新。我甚至尝试拉出一个会话变量,然后将其反馈到方法中,告诉它写什么记录(这不应该是必要的)不起作用。



有人可以偷看并告诉我他们在这里看到的问题,并给我一些指示。我有点生疏,可以帮忙。



问候,

肯......



下面是代码隐藏页面和aspx页面......



ASPX页面:

Folks this one has me baffled but that's not hard considering I've been away from code for about 5 years and now just getting pushed back into it (willingly). A lot has changed but I think I've covered all the bases here but this should have worked somewhere along the line but it doesn't.

It was working at one point but I made some formatting changed and broke it. Despite reversing back though the changes nothing fixed the break. HELP!!!

Here's what I have...

Simple gridview really aside from having several template fields in it for drop down boxed and a check box (currently turned off due to a format nightmare I'm also dealing with). The gridview is driven by a standard SqlDataSource connection with methods built for insert, update, and delete.

I've followed exampled I have found on the web nada... I've added a code behind handler to kick it a it with it's own prompting to update. I even went as far as to try and pull off a session variable to then feed that back into the method to tell it what record to write (which shouldn't be necessary) that didn't work.

Can someone take a peek and tell me what they see as the problem here and give me some pointers. I'm a bit rusty and could use some help.

Regards,
Ken...

Below is the code behind page and the aspx page...

ASPX page:

<%@ Page Title="Gap Document Revew Page" Language="vb" AutoEventWireup="true" MasterPageFile="~/Site.Master" CodeBehind="GapDocument.aspx.vb" Inherits="GETTWeb.GapDocument" EnableSessionState="True" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <table style="width: 100%;">
        <tr>
            <td>Family:</td>
            <td>Article:</td>
            <td>Document Title:</td>
            <td>Insert Element:</td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="FamilyLabel" runat="server" Text="Label" Font-Size="Large"></asp:Label></td>
            <td>
                <asp:Label ID="ArticleLabel" runat="server" Text="Label" Font-Size="Large"></asp:Label></td>
            <td>
                <asp:Label ID="DocumentTitleLabel" runat="server" Text="Label" Font-Size="Large"></asp:Label></td>
            <td>
                <asp:HyperLink ID="hyperlink1"

                    ImageUrl="AddNewButton175x80.jpg"

                    NavigateUrl="~/NewDocument.aspx"

                    Text="New Element Review Document"

                    Target="_blank"

                    runat="server" ImageWidth="79" ImageHeight="36" />
            </td>
        </tr>
    </table>
    <br />
    <asp:GridView ID="GridView1" runat="server" DataSourceID="GapDocDataSource" AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True">
        <Columns>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:CommandField ShowSelectButton="True" 

                AccessibleHeaderText="Refer To Article" 

                SelectText="View" 

                HeaderImageUrl="~/Article51x36b.gif" 

                HeaderStyle-HorizontalAlign="Center" 

                ItemStyle-HorizontalAlign="Center" 

                HeaderStyle-BackColor="#0066FF" />
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:BoundField DataField="DElement_Sub" 

                HeaderText="Ele" 

                SortExpression="DElement_Sub" 

                ItemStyle-HorizontalAlign="Center" 

                ItemStyle-Width="15" ReadOnly="True" />
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:BoundField DataField="DocID" 

                HeaderText="Doc ID" 

                SortExpression="DocID" 

                ApplyFormatInEditMode="True" 

                ReadOnly="True" 

                ItemStyle-HorizontalAlign="Center" 

                HeaderStyle-HorizontalAlign="Center">
                <HeaderStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:BoundField DataField="Doc_Name" 

                HeaderText="Support Document" 

                SortExpression="Doc_Name" 

                ControlStyle-Width="200" />
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:BoundField DataField="Doc_Section" 

                HeaderText="Refer To Section(s)" 

                SortExpression="Doc_Section" 

                ControlStyle-Width="200" />
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:TemplateField HeaderText="ENote" 

                SortExpression="Enote" ControlStyle-Width="200">
               <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ENote") %>'></asp:TextBox>
               </EditItemTemplate>
               <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("ENote") %>'></asp:Label>
               </ItemTemplate>
            </asp:TemplateField>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:TemplateField HeaderText="<center>N / A</center>" SortExpression="NotApply" Visible="False">
               <EditItemTemplate>
                   
                    <asp:CheckBox runat="server" ID="CheckBox2"

                        Checked='<%#(Eval("NotApply").ToString()) %>'

                        Width="50px" CssClass="checkbox"></asp:CheckBox>
               </EditItemTemplate>
               <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox1"

                        Checked='<%#(Eval("NotApply").ToString())%>'

                        Width="50px" CssClass="checkbox"></asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:TemplateField HeaderText="BCBS <br />MS-Windows <br />Net" SortExpression="Windows_C">
               <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" SelectedIndex='<%# Bind("Windows_C") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                    </EditItemTemplate>
               <ItemTemplate>
                    <asp:DropDownList ID="DropDownList2" runat="server" SelectedIndex='<%# Bind("Windows_C") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
               </ItemTemplate>
            </asp:TemplateField>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:TemplateField HeaderText="Cahaba <br />MS-Window <br />Net" SortExpression="Windows_G">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList3" runat="server" SelectedIndex='<%# Bind("Windows_G") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                    <%--                          The old text box for Edit                                       --%>
                    <%-- <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Windows_G") %>'></asp:TextBox> --%>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList4" runat="server" SelectedIndex='<%# Bind("Windows_G") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                    <%-- This was the code remarked out from the conversion of the field to template         --%>
                    <%-- <asp:Label ID="Label2" runat="server" Text='<%# Bind("Windows_G") %>'></asp:Label>  --%>
                </ItemTemplate>
            </asp:TemplateField>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:TemplateField HeaderText="Call Center <br />MS-Windows <br />Net" SortExpression="Windows_U">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList5" runat="server" SelectedIndex='<%# Bind("Windows_U") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList6" runat="server" SelectedIndex='<%# Bind("Windows_U") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:TemplateField HeaderText="UNIX" SortExpression="UNIX">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList7" runat="server" SelectedIndex='<%# Bind("UNIX") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList8" runat="server" SelectedIndex='<%# Bind("UNIX") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:TemplateField HeaderText="Mainframe" SortExpression="Mainframe">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList9" runat="server" SelectedIndex='<%# Bind("Mainframe") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList10" runat="server" SelectedIndex='<%# Bind("Mainframe") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:TemplateField HeaderText="IDS / IPS" SortExpression="IDS_IPS">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList11" runat="server" SelectedIndex='<%# Bind("IDS_IPS") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList12" runat="server" SelectedIndex='<%# Bind("IDS_IPS") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:TemplateField HeaderText="Network" SortExpression="Network">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList13" runat="server" SelectedIndex='<%# Bind("Network") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList14" runat="server" SelectedIndex='<%# Bind("Network") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <%-----------------------------------------------------------------------------------------------------------------%>
            <asp:TemplateField HeaderText="<center>Other</center>" SortExpression="Other">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList15" runat="server" SelectedIndex='<%# Bind("Other") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList16" runat="server" SelectedIndex='<%# Bind("Other") %>'>
                        <asp:ListItem>N/A</asp:ListItem>
                        <asp:ListItem>Gap</asp:ListItem>
                        <asp:ListItem>Upd</asp:ListItem>
                        <asp:ListItem>Current</asp:ListItem>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <%-----------------------------------------------------------------------------------------------------------------%>
        </Columns>
        <HeaderStyle BackColor="#0066FF" ForeColor="#CCFFFF" HorizontalAlign="Center" />
    </asp:GridView>
    <asp:SqlDataSource ID="GapDocDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ARFSConnectionString %>" SelectCommand="SELECT [DocID], [DElement_Sub], [Doc_Name], [ENote], [Doc_Section], [Windows_C], [Windows_G], [Windows_U], [UNIX], [Mainframe], [IDS_IPS], [Network], [Other], [NotApply] FROM [GETT_DocGaps] WHERE ([ARSDocTag] = @ARSDocTag)" DeleteCommand="DELETE FROM GETT_DocGaps WHERE (DElement_Sub = @DElement_Sub) AND (ARSDocTag = @ARSDocTag)" InsertCommand="INSERT INTO GETT_DocGaps(ARSDocTag, DElement_Sub, Doc_Name) VALUES (@ARSDocTag, @DElement_Sub, @Doc_Name)" UpdateCommand="UPDATE GETT_DocGaps SET Doc_Name = @Doc_Name, ENote = @ENote, Doc_Section = @Doc_Section, Windows_C = @Windows_C, Windows_G = @Windows_G, Windows_U = @Windows_U, UNIX = @UNIX, Mainframe = @Mainframe, IDS_IPS = @IDS_IPS, Network = @Network, Other = @Other, NotApply = @NotApply WHERE (DocID = @DocID)">
        <DeleteParameters>
            <asp:Parameter Name="DElement_Sub"></asp:Parameter>
            <asp:Parameter Name="ARSDocTag"></asp:Parameter>
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="ARSDocTag"></asp:Parameter>
            <asp:Parameter Name="DElement_Sub"></asp:Parameter>
            <asp:Parameter Name="Doc_Name"></asp:Parameter>
        </InsertParameters>
        <SelectParameters>
            <asp:SessionParameter Name="ARSDocTag" SessionField="ArticleFocus" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Doc_Name" />
            <asp:Parameter Name="ENote"></asp:Parameter>
            <asp:Parameter Name="Doc_Section"></asp:Parameter>
            <asp:Parameter Name="Windows_C"></asp:Parameter>
            <asp:Parameter Name="Windows_G"></asp:Parameter>
            <asp:Parameter Name="Windows_U"></asp:Parameter>
            <asp:Parameter Name="UNIX"></asp:Parameter>
            <asp:Parameter Name="Mainframe"></asp:Parameter>
            <asp:Parameter Name="IDS_IPS"></asp:Parameter>
            <asp:Parameter Name="Network"></asp:Parameter>
            <asp:Parameter Name="Other"></asp:Parameter>
            <asp:Parameter Name="NotApply"></asp:Parameter>
            <asp:Parameter Name="DocID"></asp:Parameter>
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>





Here is the Code behind in VB:



Here is the Code behind in VB:

Public Class GapDocument
    Inherits Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        FamilyLabel.Text = Session("FamilyFocus")
        ArticleLabel.Text = Session("ArticleFocus")
        DocumentTitleLabel.Text = Session("GapDocument")

    End Sub
    Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged
        Dim url As String = "Article.aspx"
        Dim sb As New StringBuilder()
        sb.Append("<script type = 'text/javascript'>")
        sb.Append("window.open('")
        sb.Append(url)
        sb.Append("');")
        sb.Append("</script>")
        ClientScript.RegisterStartupScript([GetType](), "script", sb.ToString())
    End Sub

    Protected Sub GridView1_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating
        'Get the Edit row
        'Dim row As GridViewRow = GridView1.Rows(e.RowIndex)
        'Dim ddl As Label = row.FindControl("DocID")

        If True Then
            Try
                'Session("DocId") = row.Cells(0).ToString
                GapDocDataSource.Update()
            Catch
            End Try
        End If
    End Sub

End Class

推荐答案

ConnectionStrings:ARFSConnectionString %>\" SelectCommand=\"SELECT [DocID], [DElement_Sub], [Doc_Name], [ENote], [Doc_Section], [Windows_C], [Windows_G], [Windows_U], [UNIX], [Mainframe], [IDS_IPS], [Network], [Other], [NotApply] FROM [GETT_DocGaps] WHERE ([ARSDocTag] = @ARSDocTag)\" DeleteCommand=\"DELETE FROM GETT_DocGaps WHERE (DElement_Sub = @DElement_Sub) AND (ARSDocTag = @ARSDocTag)\" InsertCommand=\"INSERT INTO GETT_DocGaps(ARSDocTag, DElement_Sub, Doc_Name) VALUES (@ARSDocTag, @DElement_Sub, @Doc_Name)\" UpdateCommand=\"UPDATE GETT_DocGaps SET Doc_Name = @Doc_Name, ENote = @ENote, Doc_Section = @Doc_Section, Windows_C = @Windows_C, Windows_G = @Windows_G, Windows_U = @Windows_U, UNIX = @UNIX, Mainframe = @Mainframe, IDS_IPS = @IDS_IPS, Network = @Network, Other = @Other, NotApply = @NotApply WHERE (DocID = @DocID)\">
<DeleteParameters>
<asp:Parameter Name=\"DElement_Sub\"></asp:Parameter>
<asp:Parameter Name=\"ARSDocTag\"></asp:Parameter>
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name=\"ARSDocTag\"></asp:Parameter>
<asp:Parameter Name=\"DElement_Sub\"></asp:Parameter>
<asp:Parameter Name=\"Doc_Name\"></asp:Parameter>
</InsertParameters>
<SelectParameters>
<asp:SessionParameter Name=\"ARSDocTag\" SessionField=\"ArticleFocus\" Type=\"String\" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name=\"Doc_Name\" />
<asp:Parameter Name=\"ENote\"></asp:Parameter>
<asp:Parameter Name=\"Doc_Section\"></asp:Parameter>
<asp:Parameter Name=\"Windows_C\"></asp:Parameter>
<asp:Parameter Name=\"Windows_G\"></asp:Parameter>
<asp:Parameter Name=\"Windows_U\"></asp:Parameter>
<asp:Parameter Name=\"UNIX\"></asp:Parameter>
<asp:Parameter Name=\"Mainframe\"></asp:Parameter>
<asp:Parameter Name=\"IDS_IPS\"></asp:Parameter>
<asp:Parameter Name=\"Network\"></asp:Parameter>
<asp:Parameter Name=\"Other\"></asp:Parameter>
<asp:Parameter Name=\"NotApply\"></asp:Parameter>
<asp:Parameter Name< span class=\"code-keyword\">=\"DocID\"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
</asp:Content>
ConnectionStrings:ARFSConnectionString %>" SelectCommand="SELECT [DocID], [DElement_Sub], [Doc_Name], [ENote], [Doc_Section], [Windows_C], [Windows_G], [Windows_U], [UNIX], [Mainframe], [IDS_IPS], [Network], [Other], [NotApply] FROM [GETT_DocGaps] WHERE ([ARSDocTag] = @ARSDocTag)" DeleteCommand="DELETE FROM GETT_DocGaps WHERE (DElement_Sub = @DElement_Sub) AND (ARSDocTag = @ARSDocTag)" InsertCommand="INSERT INTO GETT_DocGaps(ARSDocTag, DElement_Sub, Doc_Name) VALUES (@ARSDocTag, @DElement_Sub, @Doc_Name)" UpdateCommand="UPDATE GETT_DocGaps SET Doc_Name = @Doc_Name, ENote = @ENote, Doc_Section = @Doc_Section, Windows_C = @Windows_C, Windows_G = @Windows_G, Windows_U = @Windows_U, UNIX = @UNIX, Mainframe = @Mainframe, IDS_IPS = @IDS_IPS, Network = @Network, Other = @Other, NotApply = @NotApply WHERE (DocID = @DocID)"> <DeleteParameters> <asp:Parameter Name="DElement_Sub"></asp:Parameter> <asp:Parameter Name="ARSDocTag"></asp:Parameter> </DeleteParameters> <InsertParameters> <asp:Parameter Name="ARSDocTag"></asp:Parameter> <asp:Parameter Name="DElement_Sub"></asp:Parameter> <asp:Parameter Name="Doc_Name"></asp:Parameter> </InsertParameters> <SelectParameters> <asp:SessionParameter Name="ARSDocTag" SessionField="ArticleFocus" Type="String" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="Doc_Name" /> <asp:Parameter Name="ENote"></asp:Parameter> <asp:Parameter Name="Doc_Section"></asp:Parameter> <asp:Parameter Name="Windows_C"></asp:Parameter> <asp:Parameter Name="Windows_G"></asp:Parameter> <asp:Parameter Name="Windows_U"></asp:Parameter> <asp:Parameter Name="UNIX"></asp:Parameter> <asp:Parameter Name="Mainframe"></asp:Parameter> <asp:Parameter Name="IDS_IPS"></asp:Parameter> <asp:Parameter Name="Network"></asp:Parameter> <asp:Parameter Name="Other"></asp:Parameter> <asp:Parameter Name="NotApply"></asp:Parameter> <asp:Parameter Name="DocID"></asp:Parameter> </UpdateParameters> </asp:SqlDataSource> </asp:Content>





Here is the Code behind in VB:



Here is the Code behind in VB:

Public Class GapDocument
    Inherits Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        FamilyLabel.Text = Session("FamilyFocus")
        ArticleLabel.Text = Session("ArticleFocus")
        DocumentTitleLabel.Text = Session("GapDocument")

    End Sub
    Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged
        Dim url As String = "Article.aspx"
        Dim sb As New StringBuilder()
        sb.Append("<script type = 'text/javascript'>")
        sb.Append("window.open('")
        sb.Append(url)
        sb.Append("');")
        sb.Append("</script>")
        ClientScript.RegisterStartupScript([GetType](), "script", sb.ToString())
    End Sub

    Protected Sub GridView1_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating
        'Get the Edit row
        'Dim row As GridViewRow = GridView1.Rows(e.RowIndex)
        'Dim ddl As Label = row.FindControl("DocID")

        If True Then
            Try
                'Session("DocId") = row.Cells(0).ToString
                GapDocDataSource.Update()
            Catch
            End Try
        End If
    End Sub

End Class


RyamDev,

That’s the problem there are no error to work from. None what so ever. If there were then there would be something to work in Debug. But because it isn’t casting anything off and the data looked okay I was lost.



All,

I did get past this one issue. I will be posting a simpler question here shortly and closing this one out here with what I came up with as I did manage to get the sub functioning correctly. (just not the function)



Here is what was done:



First I had to add a public variable to the code behind so just after the opening lines I entered in:

Dim ident As String = \"\"



Then the sub which processed the update was modified so as to capture the row properly and then the unique identifier for the row ’DocID’ and put that in a session variable named the same. I tested the update method configured with and without using the session var \"DocID\" but in both cases that has failed to update. However, because the issue for which I opened this question has now been resolved I’m going to close this question and repost a simpler question regarding the update issue that might get some better focus from the group.



Here is the new sub as it is working now and it does function as intended pulling the data from the gridview1:

RyamDev,
That's the problem there are no error to work from. None what so ever. If there were then there would be something to work in Debug. But because it isn't casting anything off and the data looked okay I was lost.

All,
I did get past this one issue. I will be posting a simpler question here shortly and closing this one out here with what I came up with as I did manage to get the sub functioning correctly. (just not the function)

Here is what was done:

First I had to add a public variable to the code behind so just after the opening lines I entered in:
Dim ident As String = ""

Then the sub which processed the update was modified so as to capture the row properly and then the unique identifier for the row 'DocID' and put that in a session variable named the same. I tested the update method configured with and without using the session var "DocID" but in both cases that has failed to update. However, because the issue for which I opened this question has now been resolved I'm going to close this question and repost a simpler question regarding the update issue that might get some better focus from the group.

Here is the new sub as it is working now and it does function as intended pulling the data from the gridview1:
Protected Sub GridView1_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating
  Try
    Dim row As GridViewRow = GridView1.Rows(e.RowIndex)
    ident = row.Cells(3).Text
    Session("DocId") = ident
  Catch
  End Try
End Sub





Thanks,

Ken...



Thanks,
Ken...


这篇关于ASP.NET 4.6 Gridview / SqlDatasource已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆