I had tried something like that already, but I get an error: Dim DV As DataView DV = objdsWebvisitors.Tables("VISITOR").DefaultView DV.RowFilter = "lastname like 'J%'" '// replaced this auto-generated line '// grdWEBVISITOR.SetDataBinding(objdsWebvisitors, "VISITOR") '// with this line: grdWEBVISITOR.SetDataBinding(DV, "VISITOR") The error is: "Cannot create a child list for field VISITOR". The .SetDataBinding method expects a string as the second argument. When the first argument is a DataSet, the second argument is the name of the table. But if the first argument is a DataView, what should the second argument be? Thanks Timo [quoted text, click to view] "Bud Dean" <bud_deanREMOVEThis@hotmail.com> wrote in message news:eSes#gYfFHA.2156@TK2MSFTNGP14.phx.gbl... > Timo: > > apply your filter in this area: > > grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR") > > Create a dataview and aply the rowfilter. Then set the datasource of the > datgrid to the dataview, like Elton's example.. > > HTH, > > bud > "Timo" <Timo@spamspamspam.org> wrote in message > news:OsPyulXfFHA.3656@TK2MSFTNGP09.phx.gbl... > > Thanks, Elton. It isn't the syntax of how to create a filter that I need > > help with, but where, *in the code generated by the Data Form Wizard*, the > > filter should be applied, so that the grid on the form displays the > > matching > > rows. When I apply the filter it is having no effect on the grid. > > Regards > > Timo > > > > > > "Elton W" <EltonW@discussions.microsoft.com> wrote in message > > news:8B5018A4-E118-4F67-AB96-A38E21C219A0@microsoft.com... > >> Hi Timo, > >> > >> If you want to apply the filter to DB query, sql query is like > >> > >> SELECT * FROM VISITOR WHERE lastname LIKE 'J%' > >> > >> If you get whole data into a datatable then apply the filter, you can use > >> following code: > >> > >> Dim dv As DataView = datatable.DefaultView > >> dv.RowFilter = "lastname LIKE 'J%'" > >> > >> HTH > >> > >> Elton Wang > >> elton_Wang@hotmail.com > >> > >> "Timo" wrote: > >> > >> > I have to build dozens of simple data-entry forms in just a couple of > > days, > >> > and while I'm looking for a 3rd party tool that will help me do this, I > >> > tried the Data Form Wizard in Visual Studio, which builds a persistent > >> > dataset object based on a chosen table or view, and produces some basic > >> > code-behind. The generated routine listed below binds the dataset > >> > member > >> > (here, the VISITOR table) to a grid on the form. > >> > > >> > How and where can I modify this code to apply a filter to the VISITOR > > table, > >> > e.g. all visitors whose lastname begins with the letter 'J', so that > > only > >> > the J-names are shown in the grid? > >> > Thanks > >> > Timo > >> > > >> > '// generated by the Data Form wizard > >> > Public Sub LoadDataSet() > >> > > >> > Dim objDataSetTemp As FormsWizardTest.dsvisitors > >> > objDataSetTemp = New FormsWizardTest.dsvisitors > >> > Try > >> > > >> > Me.FillDataSet(objDataSetTemp) > >> > > >> > > >> > Catch eFillDataSet As System.Exception > >> > Throw eFillDataSet > >> > End Try > >> > > >> > > >> > Try > >> > grdVISITOR.DataSource = Nothing > >> > > >> > objdsvisitors.Clear() > >> > > >> > objdsvisitors.Merge(objDataSetTemp) > >> > grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR") > >> > > >> > grdVISITOR. > >> > > >> > Catch eLoadMerge As System.Exception > >> > > >> > Throw eLoadMerge > >> > End Try > >> > > >> > End Sub > >> > > >> > > >> > > >> > > > > > > >
Hi Timo, If you want to apply the filter to DB query, sql query is like SELECT * FROM VISITOR WHERE lastname LIKE ‘J%’ If you get whole data into a datatable then apply the filter, you can use following code: Dim dv As DataView = datatable.DefaultView dv.RowFilter = “lastname LIKE ‘J%’†HTH Elton Wang elton_Wang@hotmail.com [quoted text, click to view] "Timo" wrote: > I have to build dozens of simple data-entry forms in just a couple of days, > and while I'm looking for a 3rd party tool that will help me do this, I > tried the Data Form Wizard in Visual Studio, which builds a persistent > dataset object based on a chosen table or view, and produces some basic > code-behind. The generated routine listed below binds the dataset member > (here, the VISITOR table) to a grid on the form. > > How and where can I modify this code to apply a filter to the VISITOR table, > e.g. all visitors whose lastname begins with the letter 'J', so that only > the J-names are shown in the grid? > Thanks > Timo > > '// generated by the Data Form wizard > Public Sub LoadDataSet() > > Dim objDataSetTemp As FormsWizardTest.dsvisitors > objDataSetTemp = New FormsWizardTest.dsvisitors > Try > > Me.FillDataSet(objDataSetTemp) > > > Catch eFillDataSet As System.Exception > Throw eFillDataSet > End Try > > > Try > grdVISITOR.DataSource = Nothing > > objdsvisitors.Clear() > > objdsvisitors.Merge(objDataSetTemp) > grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR") > > grdVISITOR. > > Catch eLoadMerge As System.Exception > > Throw eLoadMerge > End Try > > End Sub > > >
I have to build dozens of simple data-entry forms in just a couple of days, and while I'm looking for a 3rd party tool that will help me do this, I tried the Data Form Wizard in Visual Studio, which builds a persistent dataset object based on a chosen table or view, and produces some basic code-behind. The generated routine listed below binds the dataset member (here, the VISITOR table) to a grid on the form. How and where can I modify this code to apply a filter to the VISITOR table, e.g. all visitors whose lastname begins with the letter 'J', so that only the J-names are shown in the grid? Thanks Timo '// generated by the Data Form wizard Public Sub LoadDataSet() Dim objDataSetTemp As FormsWizardTest.dsvisitors objDataSetTemp = New FormsWizardTest.dsvisitors Try Me.FillDataSet(objDataSetTemp) Catch eFillDataSet As System.Exception Throw eFillDataSet End Try Try grdVISITOR.DataSource = Nothing objdsvisitors.Clear() objdsvisitors.Merge(objDataSetTemp) grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR") grdVISITOR. Catch eLoadMerge As System.Exception Throw eLoadMerge End Try End Sub
Timo: apply your filter in this area: grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR") Create a dataview and aply the rowfilter. Then set the datasource of the datgrid to the dataview, like Elton's example.. HTH, bud [quoted text, click to view] "Timo" <Timo@spamspamspam.org> wrote in message news:OsPyulXfFHA.3656@TK2MSFTNGP09.phx.gbl... > Thanks, Elton. It isn't the syntax of how to create a filter that I need > help with, but where, *in the code generated by the Data Form Wizard*, the > filter should be applied, so that the grid on the form displays the > matching > rows. When I apply the filter it is having no effect on the grid. > Regards > Timo > > > "Elton W" <EltonW@discussions.microsoft.com> wrote in message > news:8B5018A4-E118-4F67-AB96-A38E21C219A0@microsoft.com... >> Hi Timo, >> >> If you want to apply the filter to DB query, sql query is like >> >> SELECT * FROM VISITOR WHERE lastname LIKE 'J%' >> >> If you get whole data into a datatable then apply the filter, you can use >> following code: >> >> Dim dv As DataView = datatable.DefaultView >> dv.RowFilter = "lastname LIKE 'J%'" >> >> HTH >> >> Elton Wang >> elton_Wang@hotmail.com >> >> "Timo" wrote: >> >> > I have to build dozens of simple data-entry forms in just a couple of > days, >> > and while I'm looking for a 3rd party tool that will help me do this, I >> > tried the Data Form Wizard in Visual Studio, which builds a persistent >> > dataset object based on a chosen table or view, and produces some basic >> > code-behind. The generated routine listed below binds the dataset >> > member >> > (here, the VISITOR table) to a grid on the form. >> > >> > How and where can I modify this code to apply a filter to the VISITOR > table, >> > e.g. all visitors whose lastname begins with the letter 'J', so that > only >> > the J-names are shown in the grid? >> > Thanks >> > Timo >> > >> > '// generated by the Data Form wizard >> > Public Sub LoadDataSet() >> > >> > Dim objDataSetTemp As FormsWizardTest.dsvisitors >> > objDataSetTemp = New FormsWizardTest.dsvisitors >> > Try >> > >> > Me.FillDataSet(objDataSetTemp) >> > >> > >> > Catch eFillDataSet As System.Exception >> > Throw eFillDataSet >> > End Try >> > >> > >> > Try >> > grdVISITOR.DataSource = Nothing >> > >> > objdsvisitors.Clear() >> > >> > objdsvisitors.Merge(objDataSetTemp) >> > grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR") >> > >> > grdVISITOR. >> > >> > Catch eLoadMerge As System.Exception >> > >> > Throw eLoadMerge >> > End Try >> > >> > End Sub >> > >> > >> > >> > > >
Thanks, Elton. It isn't the syntax of how to create a filter that I need help with, but where, *in the code generated by the Data Form Wizard*, the filter should be applied, so that the grid on the form displays the matching rows. When I apply the filter it is having no effect on the grid. Regards Timo [quoted text, click to view] "Elton W" <EltonW@discussions.microsoft.com> wrote in message news:8B5018A4-E118-4F67-AB96-A38E21C219A0@microsoft.com... > Hi Timo, > > If you want to apply the filter to DB query, sql query is like > > SELECT * FROM VISITOR WHERE lastname LIKE 'J%' > > If you get whole data into a datatable then apply the filter, you can use > following code: > > Dim dv As DataView = datatable.DefaultView > dv.RowFilter = "lastname LIKE 'J%'" > > HTH > > Elton Wang > elton_Wang@hotmail.com > > "Timo" wrote: > > > I have to build dozens of simple data-entry forms in just a couple of days, > > and while I'm looking for a 3rd party tool that will help me do this, I > > tried the Data Form Wizard in Visual Studio, which builds a persistent > > dataset object based on a chosen table or view, and produces some basic > > code-behind. The generated routine listed below binds the dataset member > > (here, the VISITOR table) to a grid on the form. > > > > How and where can I modify this code to apply a filter to the VISITOR table, > > e.g. all visitors whose lastname begins with the letter 'J', so that only > > the J-names are shown in the grid? > > Thanks > > Timo > > > > '// generated by the Data Form wizard > > Public Sub LoadDataSet() > > > > Dim objDataSetTemp As FormsWizardTest.dsvisitors > > objDataSetTemp = New FormsWizardTest.dsvisitors > > Try > > > > Me.FillDataSet(objDataSetTemp) > > > > > > Catch eFillDataSet As System.Exception > > Throw eFillDataSet > > End Try > > > > > > Try > > grdVISITOR.DataSource = Nothing > > > > objdsvisitors.Clear() > > > > objdsvisitors.Merge(objDataSetTemp) > > grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR") > > > > grdVISITOR. > > > > Catch eLoadMerge As System.Exception > > > > Throw eLoadMerge > > End Try > > > > End Sub > > > > > > > >
I found out the answer-- second argument can be String.Empty Thanks for the help. Timo
Don't see what you're looking for? Try a search.
|