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>
<%----%>
<%----%>
</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>
<%----%>
<%----%>
</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:
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
If True Then
Try
GapDocDataSource.Update()
Catch
End Try
End If
End Sub
End Class