Thanks for your quick reply Bill, I will be more specific ;)
The tables are named: HVE_LGS_05_Object and HVE_LGS_20_Generatorblad (among a few other tables in my application).
(Don't mind the images, I just had to put in something...)
As you can see, the "Select" button and the "Edit" button are Gridview buttons, but the Image sits on an "Imagebutton".
The column "Object" (with the text like "DUO64-1 in it) holds the objectnames that link to the other table records.
The Object gridview is coded:
==============================================
<asp:GridView ID="GridView1"
runat="server"
AllowPaging="True"
AutoGenerateColumns="False"
DataKeyNames="Object0_ID"
DataSourceID="VDW_GetAllHVE_LGS_05_Object"
EnableViewState="False"
HeaderStyle-BackColor="Red"
HeaderStyle-Font-Bold="True"
HeaderStyle-ForeColor="White"
OnRowCommand="VDW_GridView_RowCommand">
<PagerSettings Mode="Numeric" Position="Bottom"/>
<PagerStyle BackColor="LightBlue" Height="30px" HorizontalAlign="Center" VerticalAlign="Bottom"/>
<Columns>
<asp:CommandField ShowDeleteButton="False" ShowEditButton="False"/>
<asp:ButtonField ButtonType="Button" CommandName="Select" HeaderText="Select" Text="Select" Visible="True"/>
<asp:BoundField DataField="Object0_ID" HeaderText="Object0_ID" Visible="True"/>
<asp:BoundField DataField="Object1_Portal_ID" HeaderText="Portal" Visible="False"/>
<asp:BoundField DataField="Object2_Module_ID" HeaderText="Module" Visible="False"/>
<asp:BoundField DataField="Object3_Tab_ID" HeaderText="Tab" Visible="False"/>
<asp:BoundField DataField="Object4_Localisation" HeaderText="Localisation" Visible="False"/>
<asp:BoundField DataField="Object5_User_ID" HeaderText="User" Visible="False"/>
<asp:BoundField DataField="Object6_User_Name_DNN" HeaderText="User" Visible="False"/>
<asp:BoundField DataField="Object7_Date_modified_DTE" HeaderText="Date" Visible="False"/>
<asp:BoundField DataField="Object8_ObjectCode_GRD" HeaderText="ObjectCode" Visible="True"/>
<asp:BoundField DataField="Object9_Object_SQLSEL_SQLSRTA_GRD_OCSCD_LKTRID" HeaderText="Object" Visible="True"/>
<asp:BoundField DataField="Object10_MachineGroep0_ID" HeaderText="MachineGroep0" Visible="False"/>
<asp:BoundField DataField="Object11_MachineGroep_DDL" HeaderText="MachineGroep" Visible="False"/>
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:ImageButton Id="btnImage" runat="server" OnClick="btnImgSelect_Click" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Object12_Generatorblad_GRD_IMG_IBTTN")%>' style="border-style:OutSet; height:120px; margin-top:0px" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Object13_Locatie0_ID" HeaderText="Locatie0" Visible="False"/>
<asp:BoundField DataField="Object14_Locatie_DDL" HeaderText="Locatie" Visible="False"/>
<asp:BoundField DataField="Object15_FlowCascade0_ID" HeaderText="FlowCascade0" Visible="False"/>
<asp:BoundField DataField="Object16_FlowCascade_DDL_FCSCD_LBX" HeaderText="FlowCascade" Visible="False"/>
<asp:BoundField DataField="Object17_Technoloog0_ID_SPF" HeaderText="Technoloog0" Visible="False"/>
<asp:BoundField DataField="Object18_Technoloog_USR_GRD" HeaderText="Technoloog" Visible="True"/>
<asp:ButtonField ButtonType="Button" CommandName="Edit" HeaderText="Edit" Text="Edit" Visible="True"/>
</Columns>
<EmptyDataTemplate>
The Object table is empty!
</EmptyDataTemplate>
</asp:GridView>
==============================================
The main (Objects) table has an imagebutton in the gridview that triggers a subroutine like this:
==============================================
Public Sub btnImgSelect_Click(ByVal Sender As Object, ByVal e As EventArgs)
'================ Start TraceLog ================
strItem = "Button Handlers: btnImgSelect_Click"
strDetail = "e.EventArgs" & e.ToString
strResult = "TRY"
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================
Try
Dim gvSelectedRow As GridViewRow = CType(CType(sender, Control).Parent.Parent, GridViewRow)
Dim gvRowIndex As Integer = gvSelectedRow.RowIndex
lstKeepListTableRecordSelection = Session("ListTableRecordSelection")
'================ Start TraceLog ================
strItem = "Button Handlers: btnImgSelect_Click"
strDetail = "Selected row: " & gvRowIndex.ToString
strResult = "Go for: " & lstKeepListTableRecordSelection(gvRowIndex)
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================
Dim gvRowIndexContent As String = ""
Dim strParameters As String = ""
Dim strSQL As String = "Select Object9_Object_SQLSEL_SQLSRTA_GRD_OCSCD_LKTRID,Object16_FlowCascade_DDL_FCSCD_LBX From HVE_LGS_05_Object Where Object0_ID = '" & lstKeepListTableRecordSelection(gvRowIndex) & "'"
Dim dbConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("SiteSqlServer"))
Dim dbDataReader As SqlDataReader
dbConnection.Open()
Dim dbCommand As SqlCommand = New SqlCommand(strSQL, dbConnection)
dbDataReader = dbCommand.ExecuteReader(CommandBehavior.CloseConnection)
While dbDataReader.Read
gvRowIndexContent = dbDataReader.GetString(0)
strParameters = dbDataReader.GetString(1)
'================ Start TraceLog ================
strItem = "Datareaders: START find_Object"
strDetail = "RowIndexContent: " & dbDataReader.GetString(0)
strResult = "Parameters: " & dbDataReader.GetString(1)
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================
End While
If Not dbDataReader Is Nothing Then
dbDataReader.Close()
End If
Dim strURL = HttpContext.Current.Request.Url.AbsoluteUri
Dim intPos As Integer = strURL.IndexOf("Default.aspx")
strURL = Left(strURL, intPos)
'================ Start TraceLog ================
strItem = "Button Handlers: btnImgSelect_Click"
strDetail = "strURL: " & strURL
strResult = "RecordID: " & gvRowIndexContent
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================
strRedirectTo = strURL & GetModulePathSettings() & ".aspx?RecordID=" & gvRowIndexContent
Response.Cookies(strApplication_Prefix & "GetRecord")("RecordID") = gvRowIndexContent
Dim SetRecord As HttpCookie = New HttpCookie("SetRecordInfo")
SetRecord.Values.Add("ObjectName", gvRowIndexContent)
SetRecord.Values.Add("Parameters", strParameters)
Response.Cookies.Add(SetRecord)
'================ Start TraceLog ================
strItem = "Button Handlers: btnImgSelect_Click"
strDetail = "Page.IsPostBack = " & Page.IsPostBack.ToString
strResult = "strRedirectTo: " & strRedirectTo
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================
Catch Exc As Exception 'Module failed to load
Session("App_Title") = "Error in table link"
Session("App_Message") = "The tablename that this link points to does not exist! Call your developer."
mErrMessage += " " & Exc.Message
'================ Start TraceLog ================
strItem = "### ERROR: Button Handlers: btnImgSelect_Click"
strDetail = "strSQLFileNames: " & strSQLFileNames
strResult = "### ERROR: " & mErrMessage
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================
Finally
'Clean up.
'If dbDataReaderTableNames IsNot Nothing Then
' dbDataReaderTableNames.Close()
' dbDataReaderTableNames.Dispose()
'End If
End Try
End Sub
==============================================
But the problem is that this routine will NOT fire from the 10th Object gridview row.
Gridviewrows 1 thru 9 works fine!.
BIG MISTERY!
Thanks,
Jos