I have the problem with RadGridView.
How to fill RadGridView with only selected field from dataset.
I have 4 field in dataset, and only field BERAT that only i want to fill to datagrid.
How can make this happen.
The field is : NoTransaksi, NoUrut, Berat
12 Answers, 1 is accepted
Thank you for writing.
You can refer to the following stackOverflow threads demonstrating how to fill a DataTable from query selecting the specific columns:
Afterwards, you can set the DataTable as RadGridView.DataSource.
An alternative solution is to hide the undesired columns by setting the IsVisible property to false of the specific column.
I hope this information helps. Should you have further questions I would be glad to help.
Thanks for reply... for the solution you gave to me. I have did it but the problem is
the grid can be to input and show the data.
it can be done with add the data manually. with for looping. but i want to know if there another way to fill the data from dataset.
so i just bind the column to dataset.
(hope you understand with what i mean)
Or how to bind the field direct to the column
Thank you for writing back.
If you have filled the DataTable successfully, you can use it as DataSource for RadGridView. You can find additional information in the GridView >> Populating with Data section in the online documentation.
As to the question about binding the field directly to the column when the column is added programmatically, it is necessary to specify the FieldName property of the column. A sample code is available here: http://www.telerik.com/help/winforms/gridview-columns-gridviewtextboxcolumn.html
I hope this information helps. If you have any additional questions, please let me know.
This what i do manual for fill the data to gridview
cmd = New SqlCommand("SELECT * FROM TrManualDtl WHERE NoTransaksi='" & LblNoTransaksi.Text & "' ORDER BY NoUrut", conn)
rd = cmd.ExecuteReader
how to bind direct from dataadapter or datareader this code what i tried ... but not solved my problem
'da = New SqlDataAdapter("Select * from TrManualDtl Where NoTransaksi='" & GridListManual.Rows(i).Cells(0).Value.ToString() & "' ORDER BY NoUrut", conn)
'ds = New DataSet
'GridManual.Columns(0).FieldName = "Berat"
''GridManual.DataSource = (ds.Tables("TrManualDtl"))
Thank you for writing back.
I am sending you attached a project demonstrating how you can load data in RadGridView using a DataReader object. The example includes two grids using the same data, the first one has auto-generated columns while the second one uses columns defined at design-time. The columns of the second grid are mapped to the data object via their FieldName property as my colleague explained earlier.
Additional information is available here:
I am also attaching a short animation showing the result on my end.
I hope this helps. Should you have further questions please do not hesitate to write back.
Hello Jehad trying to help ...
It's because u set the column diffrent with your's table ...
please check the table in your's query ...
Everything is right, the table and the query, you can try the attached project in Hristos' post.
It's repeating the columns.
Hi Jehad ... i have tried it a long time ago and it's working fine ..
Please see the attached picture. This screen for same project without change anything in the code.
only change some designer code because of the version like:
this.radGridView2.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
this.radGridView2.MasterGridViewTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
gridViewTextBoxColumn1.Name = "column1";
gridViewTextBoxColumn1.UniqueName = "column1";
I have downloaded the project provided by Hristo on 13 Jan 2016. Please refer to the attached gif file illustrating the behavior on my end with the latest version.
The three added columns remain in the right grid control. As to the specified changes, I would like to note that GridViewTextBoxColumn doesn't offer a UniqueName property.
Could you please specify what are the exact changes that you made in the code or at design time in the prject which results in the multiple columns displayed on your end with Hristo's project?
I am looking forward to your reply.
Dess | Tech Support Engineer, Sr.