Jeg har forsøgt nu at lave en simplificeret udgave på samme problem. Jeg sender her koden. Problemet er det samme. Navnene er lidt anderledes end tidligere, men lad os tage den herfra. tak for at du hænger på Neoman:)
codebehind:
Imports System.Data.SqlClient
Imports System.Data
Imports System.IO
Partial Class test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim intlen, intpos As Integer
intpos = InStr(Request.ServerVariables("LOGON_USER"), "\") 'uddrager logonnavn af "DK\at"
intlen = Len(Request.ServerVariables("LOGON_USER")) 'uddrager logonnavn af "DK\at"
Session("userittasks") = LCase(Trim(Right(Request.ServerVariables("LOGON_USER"), intlen - intpos)))
End Sub
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs)
Dim myGridView As GridView
Dim rowindex As Integer
rowindex = 1
While rowindex < 4
myGridView = CType(DetailsView1.Rows(rowindex).FindControl("GridView1"), GridView)
Dim dd As Label = CType(myGridView.FindControl("Label1"), Label)
rowindex = rowindex + 1
End While
' Dim xx As Label = CType(GridView2.Rows(e.RowIndex).findcontrol("Labelfilename"), Label)
End Sub
End Class
---------- og siden
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="GUID"
DataSourceID="DS_edit" Height="50px" Width="397px">
<Fields>
<asp:BoundField DataField="Taskno" HeaderText="Taskno" SortExpression="Taskno" />
<asp:BoundField DataField="GUID" HeaderText="GUID" ReadOnly="True" SortExpression="GUID" />
<asp:TemplateField HeaderText="Attachedfiles" SortExpression="Attachedfiles">
<EditItemTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Taskno,seq"
DataSourceID="DS_attach" OnRowDeleting="GridView1_RowDeleting">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:TemplateField HeaderText="filename" SortExpression="filename">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("filename") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("filename") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="DS_attach" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ITtasksConnectionString %>" DeleteCommand="DELETE FROM [Attachments] WHERE [Taskno] = @original_Taskno AND [seq] = @original_seq"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [filename], [Taskno], [seq], [Task_GUID] FROM [Attachments] WHERE ([Task_GUID] = @Task_GUID)"
>
<DeleteParameters>
<asp:Parameter Name="original_Taskno" Type="Int32" />
<asp:Parameter Name="original_seq" Type="Int32" />
<asp:Parameter Name="original_filename" Type="String" />
<asp:Parameter Name="original_Task_GUID" Type="Object" />
</DeleteParameters>
<SelectParameters>
<asp:ControlParameter ControlID="DetailsView1" Name="Task_GUID" PropertyName="SelectedValue"
Type="Object" />
</SelectParameters>
</asp:SqlDataSource>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Attachedfiles") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:SqlDataSource ID="DS_attach" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ITtasksConnectionString %>" DeleteCommand="DELETE FROM [Attachments] WHERE [Taskno] = @original_Taskno AND [seq] = @original_seq AND [filename] = @original_filename AND [Task_GUID] = @original_Task_GUID"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [Taskno], [seq], [filename], [Task_GUID] FROM [Attachments] WHERE ([Task_GUID] = @Task_GUID)">
<DeleteParameters>
<asp:Parameter Name="original_Taskno" Type="Int32" />
<asp:Parameter Name="original_seq" Type="Int32" />
<asp:Parameter Name="original_filename" Type="String" />
<asp:Parameter Name="original_Task_GUID" Type="Object" />
</DeleteParameters>
<SelectParameters>
<asp:ControlParameter ControlID="DetailsView1" Name="Task_GUID" PropertyName="SelectedValue"
Type="Object" />
</SelectParameters>
</asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="DS_edit" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ITtasksConnectionString %>"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [Taskno], [GUID], [Attachedfiles] FROM [tasks] WHERE ([GUID] = @GUID)"
UpdateCommand="UPDATE [tasks] SET [Taskno] = @Taskno, [Attachedfiles] = @Attachedfiles WHERE [GUID] = @original_GUID AND [Taskno] = @original_Taskno AND [Attachedfiles] = @original_Attachedfiles">
<UpdateParameters>
<asp:Parameter Name="Taskno" Type="Int32" />
<asp:Parameter Name="Attachedfiles" Type="String" />
<asp:Parameter Name="original_GUID" Type="Object" />
<asp:Parameter Name="original_Taskno" Type="Int32" />
<asp:Parameter Name="original_Attachedfiles" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:Parameter DefaultValue="6100848b-ec9c-4504-9c07-5d5b16e65eb6" Name="GUID" Type="string" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="Taskno" Type="Int32" />
<asp:Parameter Name="GUID" Type="Object" />
<asp:Parameter Name="Attachedfiles" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>