Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesOdd behaviour in DataGrid;please advise!Odd behaviour in DataGrid;please advise!
Previous
 
Next
New Post
8/30/2012 5:57 AM
 

Hello,

I am developing an application that hat two tables in it. The tables are listed in a standard fasion using the GridView and an Editing page for the individual selected record. The relationship between the records in the tables (Objects and GeneratorSheet) is 1:N, so one object can have 0, 1 or more Generatorsheets linked to it.

The two tables are connected by a mutual record object identifier in each table, and there is an image button in the main table that fires a sub routine that opens the second table.It takes the object identifier as a parameter to the other table and lists the selected records in the datagrid of that secundary tableview.

Furthermore: the records are sorted by the Object identifier, so the record indexes are in random order.

Now the strange part: This works only for the first 10 records in the Object table! When I select the 10th or higher Object record, the gridview returns that Objectrecords, instead of opening the GeneratorSheet module. And the sorting is on the record index instead of the Object identifier.

I checked all the code and tables, but I can't find any clue as where to look for the mistake.

Please help!

Thanks,

Jos

 

 

 
New Post
8/30/2012 6:29 AM
 
Jos,

When you select a record in table 1 it should run a SQL script that uses the key value to only load items in table 2 that equal the key value.

I do hope your table is not really called Object.

regards,
Bill
 
New Post
8/30/2012 7:03 AM
 

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).

 

Select Object0_ID ObjectCode Object Image Technoloog Edit
29 Obj26 Agietron Joost
24 Obj21 BES-SL74 Joost
25 Obj22 DUO64-1 Jan Willem

(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

 
New Post
8/30/2012 8:26 AM
 
Jos,

That will be because gvRowIndex can only ever be 0 thru 9 in a 10 row table.

I would recommend you move the sql code into stored procedures and test each procedure as you write it to ensure what you are getting back is what you expect.

If DUO64-1 is the link to the second table then I would expect code along the lines of

ParameterName = GridView1.SelectedRow.Cells(3).Value

StoredProcedureName(ParameterName)

--
and the Stored Procedure would be along the lines of

SELECT list of table fileds from Table2
WHERE KeyColumnName.Value = %ParameterName

Hope that helps you.

Bill





 
New Post
8/30/2012 9:11 AM
 

Thanks Bill,

but my gridview contains approx 30 records, so the gvRowIndex can be any value between 0 and 30....

Unfortunately I can't move the SQL into a stored procedure, because I build my code thru my codegenerator called "JumpStart DNN" (You might check out my website: www.visualdata.nl)

I gueass that the problem originates in the sorting of my tables and that, in one way or another, this sort conflicts somewhere. I can't either find the reason why the malfunction of the link to the second table is at recordnumber 10.....

I have removed any properties from the datagrid that might set the grid to 10 rows.....

But when the module returns from a faulty link, it shows the gridview from the Objects table in sets of 10 records and the sorting in on SQL recordnumber instead of the Object identifier.

I'm lost....

Jos

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesOdd behaviour in DataGrid;please advise!Odd behaviour in DataGrid;please advise!


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out