I have enquiry on how to parse data of sub DataGridView to the main DataGridView. For example:
I have a column named "abnormal" on the main DataGridView and I need the data for avail column from the sub DataGridView to display on the main DataGridView "abnormal" column. I have tried the CustomCallBack but it doesn't work. The error that appeared:
"DataBinding: 'DevExpress.Web.Data.WebDataRow' does not contain a property with the name 'isAvail'`
My code : The main DataGridView id is disgrid and the sub DataGridView is detgrid
The code for main DataGridView abnormal column (asp.net)
<dx:ASPxGridView ID="DisGridx" runat="server" OnCustomUnboundColumnData="griddata" OnHtmlDataCellPrepared="gridcell" ClientIDMode ="Static" ClientInstanceName="DisGridx" Width="100%" KeyFieldName="ID" " >
<dx:GridViewDataTextColumn FieldName="abnormal" Caption="Abnormal" >
<DataItemTemplate>
<dx:ASPxHyperLink ID="ASPxHyperLink" runat="server" Text='<%# Eval("[isAvail]") %> ' ClientSideEvents-Click='<%# "function(s,e) { DetGridx.PerformCallback(""" & Eval("ID").ToString & """); contentpop2();}" %>' >
</dx:ASPxHyperLink>
</DataItemTemplate>
</dx:GridViewDataTextColumn>
The code for DetGridx (asp.net)
<dx:ASPxGridView ID="DetGridx" runat="server" ClientIDMode="Static" OnCustomCallback="DetGridx_CustomCallback" OnHtmlDataCellPrepared="DetGridx_HtmlDataCellPrepared" OnDataBinding="DetGridx_DataBinding" ClientInstanceName ="DetGridx" KeyFieldName="ID"
The code for main DataGridView (vb.net)
..................................
Dim csvFileFolder As String = "C:\New folder\"
Dim csvFile As String = "QtimeAutomotiveByLot_New.csv"
Dim adapter2 As New OleDbDataAdapter
' specify directory path containing CSV file as data source
Dim strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + csvFileFolder + ";Extended Properties='Text;HDR=YES;FMT=Delimited';"
Dim connx As New OleDbConnection(strCon)
connx.Open()
' To display file from csv
Dim sql As New OleDbCommand("Select distinct(ID),COUNT(isAvail) as isAvail from [" + csvFile + "] where isAvail = 0 group by ID, isAvail ", connx)
adapter2.SelectCommand = sql
adapter2.Fill(ds,"csv")
connx.Close()
ds.Tables("lotlist").PrimaryKey = New DataColumn() {ds.Tables("lotlist").Columns("ID")}
ds.Tables("comd").PrimaryKey = New DataColumn() {ds.Tables("comd").Columns("ID")}
ds.Tables("monitor").PrimaryKey = New DataColumn() {ds.Tables("monitor").Columns("ID")}
ds.Tables("csv").PrimaryKey = New DataColumn() {ds.Tables("csv").Columns("ID")}
dt.Merge(ds.Tables("lotlist"))
dt.Merge(ds.Tables("comd"))
dt.Merge(ds.Tables("monitor"))
dt.Merge(ds.Tables("csv"))
Dim dv1 As DataView = dt.DefaultView
dv1.RowFilter = "[Cat] <> '' "
DisGridx.DataSource = dv1
DisGridx.DataBind()
The code for DetGridx customcallback vb.net
Protected Sub DetGridx_CustomCallback(sender As Object, e As ASPxGridViewCustomCallbackEventArgs)
Dim sql As New OleDbCommand("Select * from [" + csvFile + "] where ID = 'L-" + e.Parameters + "' AND STEPHANDLE = (SELECT TOP 1 STEPHANDLE from [" + csvFile + "] WHERE ID = '" + e.Parameters + "')", connx)
adapter2.SelectCommand = sql
adapter2.Fill(dt1)
connx.Close()
DetGridx.DataSource = dt1
DetGridx.DataBind()
End Sub
Can anyone guide me on this? Or providing a similar example for me to refer is good enough.
Sample and expected output:
Main Gridview Sub Grid View
Abnormal ID ID Note isAvail
0/3 kiv-02 kiv-02 1-2 0
kiv-02 1-3 0
kiv-02 1-4 0
Thanks in advance.
Attempt :
add ds.Tables("dat").PrimaryKey = New DataColumn() {ds.Tables("dat").Columns("isAvail")}
to maingrid function
error : these columns dont currently have unique values.
Probably you need to slightly change
Eval("isAvail")
toEval("[isAvail]")
like this:Or by checking
Container.DataItemPosition
before usingDataBinder.Eval()
:The exception in
WebDataRow
occurs becauseEval()
(andBind()
expressions) tries to rebind the grid at runtime andDisGridx
doesn't assigned with data source yet (i.e. theASPxGridView
column hierarchy built earlier than assigningDataSource
property, see the explanation here).References:
'DevExpress.Web.Data.WebDataRow' does not contain a property with the name
'DevExpress.Web.Data.WebDataRow' does not contain a property with the name 'X'