Top 45 Datagrid Interview Questions You Must Prepare 02.Oct.2022

In older versions of TOAD, the grid is limited to adding/modifying CLOB's for existing records. This should be working in TOAD 7.@Note, however, that since TOAD does not support Unicode databases, that there are often errors when viewing CLOB data in the data grids for databases with Unicode character sets.

  • Web Forms have the collection of pages that perform the round trip for the processing on the server. Whereas, Windows Forms doesn’t perform that well on the processing front. 
  • Web Forms DataGrid control uses less built-in functionality, whereas, Windows Forms uses more built-in functionality. 
  • Web Forms DataGrid control doesn’t support detailed master data structure, whereas, Windows Forms supports the data structure. 
  • Web Forms DataGrid control supports the two way binding and the automation is being done for the data, whereas, Windows Forms doesn’t provide two way binding and manual code need to be written. 
  • Web Forms allow users to edit only one row at a time and doesn’t have support for sorting and no event handles, whereas, Windows Forms provide all that.

Try upgrading to the current release of TOAD, as we have obtained an updated XLS component. If you are still experiencing the problem, you can do this: FORMAT ? CELLS ? NUMBER TAB ? change to Currency, Percentage, etc.

  • Columns can be added in their own way by making two different columns and adding them using the function of Column.Add().
  • The order of the columns is not determined by the order in which they are shown or stored. To list the order use of DisplayIndex property is used. 
  • To add the columns that are binded with one another first there is a need to create the data and add the data to the items collection. 
  • XAML is used to instantiate and initialize the two columns and produces the same result with the in-built function as normal language. 

<DataGrid Height="50" 
HorizontalAlignment="Right" 
Margin="7,9,0,0" 
Name="dataGrid" 
VerticalAlignment="Top" 
Width="100" >
<DataGrid.Columns>
<DataGridTextColumn 
Binding="{Binding Path=name}" 
Header="Name">
</DataGridTextColumn>
<DataGridTextColumn 
Binding="{Binding Path=age}
Header="Age">
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>

  • Binding works on the basis of specifying an object and a property to the object that needs to be binded. 
  • The property of the object is stored and retrieved of the data that is involved in binding. 
  • The collection of data is being stored in a Data Grid and it is being provided by using CollectionView object that determines all the objects in the collection to be used as binding. 
  • CollectionView object points always to the current item that is being bound to a single object and consists of single property. 
  • The CollectionView is used as a base class and it can be used to navigate the object’s current position throughout the collection. 
  • The DataContext is being set to one of the objects with the paths already defined that is being pointed to the binding object assigned to a column.

TOAD 7.5 and up can show TIMESTAMP and INTERVAL data in its data grids if you are using a 9.0.1 or higher Oracle client. TOAD 9.0.1 supports TIMESTAMP and INTERVAL data in its "run as script" function. TOAD versions 7.4 and previous do not support TIMESTAMP and INTERVAL data due to a limitation in their data layer. 

To see timestamp/intervals in the "datatype" drop down in the Create/Alter Table window, and in the "Add Column" window, go to options ? datatypes, and make sure "Include Timestamp/Interval Types" is checked.

The different column types used in DataGrid are as follows:

  1. BoundColumn: this type is used to display the field in a data source. The field consists of an item in the form of text. This is the default column type in DataGrid control. 
  2. ButtonColumn: this type is used to display the column that consists of editing commands used in the column. 
  3. HyperLinkColumn: this type displays the content of item in the column as a hyperlink. The content can be in the form of a text or it can have an association with other fields. 
  4. TemplateColumn: this type displays the item according the template and it also allow the creation of custom controls for the templates.

  1. The update strategy is inefficient to provide the updates to the database for each of the grid row. 
  2. The updates sent are not sufficient to show the changes that are being made every minute/seconds. 
  3. Manual logic needs to be updated to check for the changes that has taken place between the controls in a particular row in grid. 
  4. Comparisons are hard to make between different datasets and databases that involves a round trip. 
  5. No checking of the database take place to see the updations and changes made in it after some time.

Please upgrade your copy of TOAD to at least version 7.4.0.@This functionality has been restored.

  1. The columns can be manually defined by using the property AutoGenerateColumns and change that property to False. 
  2. The columns need to be defined in the columns collection and in the data grid area. 

The program that will make the columns is:

DataGridCheckBoxColumn // to define the boolean values
DataGridComboBoxColumn // to define the enumerable values
DataGridHyperlinkColumn // to define the Uri values
DataGridTemplateColumn // to define the types of data for the cell template
DataGridTextColumn // to define text values
<DataGrid ItemsSource="{Binding_Products}" AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTemplateColumn Header="Image" Width="SizeToCells" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding_Image}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>

Dataset:

  • DataSet object can contain multiple rowsets from the same data source as well as from the relationships between them.
  • Dataset is a disconnected architecture
  • Dataset can persist data.

Datareader:

  • DataReader provides forward-only and read-only access to data.
  • Datareader is connected architecture
  • Datareader can not persist data.

Reset NLS_LANG on your Client machine to AMERICAN_AMERICA.JA16SJIS to view Japanese and AMERICAN_AMERICA.ZHT16BIG5 to view Chinese. Then change the font script for each language by right clicking on the data and choosing Grid Options | Data Grids - Visual | Fonts | Grid and choose Arial Unicode MS as the Font. This changes the script to Japanese for Japanese characters or to ChineseBig5 for Chinese.

We have found that this happens when the database character set is WE8ISO8859P1, and the Oracle client is 9.2.0.@This is an Oracle bug, and upgrading your client to 9.2.0.4 or higher should resolve the problem. In any other case, please generate a TOAD Support Bundle from the Help menu and let us know what you are seeing.

  • The data grid includes the selection modes that can be configured and customized according to the requirements. 
  • It includes the selection modes property as SelectionMode and SelectionUnit. 
  • The selection mode of the data grid can be set to either single or extended. This way it defines the selection of one or more units. 
  • SelectionUnit is used to define the scope of one selection unit in regarlds to the cell row by using the data as Cell, CellAndRowHeader and FullRow.

The program is as follows:

<DataGrid ItemsSource="{Binding_Products}" 
SelectionMode="Extended" SelectionUnit="Cell" />

  • DataGrid provides a way to edit the data and set the properties to create a good user interface. 
  • DataGrid provides a way to create an application that provides interactivity by using the set or unset of the methods like CanUserAddRows, CanUserDeleteRows, CanUserReorderColumns, etc. 
  • To edit look for the properties that starts with CAN and change it according to the requirements. 
  • Adding or modifying of a row or data effects the collection of the Items that is assigned to the ItemsSource.

Yes, for this you have to use datatable and after inserting the first row in datatable You have to bind that datatable to the grid and next time , first you have to add the row in datatable and next bind it to datagrid. keep on doing. You have to maintain the datatable state.

  • External IEnumerables are used to collect the collection of Items that are supplied with the DataGrid. 
  • The data that is being displayed is usually having external sources like database connection so DataGrid uses an external collection object. 
  • Before collection any data it is important to set the ItemsSource property and an object type is created to hold the data. 

The example of holding the object type is shown below: 

public class Person
{
public string name { set; get; } 
public int age { set; get; }
public bool member { set; get; }
}

Collection of these objects needs to be created for the listing of them: 

List<Person> myList = new List<Person>();
myList.Add(new Person() {name="hello",age=30,member=true});
myList.Add(new Person() {name="yello",age=25,member=false});
myList.Add(new Person() {name="mello",age=15,member=true});

To display the collection the DataGrid object is used like:

dataGrid.ItemsSource=makeList;

cvv using template column we can very well add date time control as child control.

TOAD 7.5 and up can show nested table data in popups from the data grids if you are using an 8.0 or higher Oracle client. The nested table data will appear in the grid cell as "(DATASET)". Right-click over this cell and choose "Popup editor". TOAD 9.0.1 now supports nested table data in its "run as script" function. TOAD versions 7.4 and previous do not support nested table data due to a limitation in their data layer.

  • DataGrid control allows the user to modify and manage the records without adding the new ones. To add the functionality following things need to be done:
  • Add a new record in the data source for the grid and assign an ID to the record. 
  • Put a placeholder values in the properties area for columns and make a column such that it can’t be null. 
  • Rebind the DataGrid control to the source through which the modification can be done. 
  • Determine the place where the record will appear on the grid. 
  • Update the record so that it will be automatic when the user clicks on it or updates a link or a new record is added.

  1. DataGrid shows the properties in the form of columns and each column store some value. 
  2. DataGrid need two columns and each of them is bound to have one property each and that is also different from one another. 
  3. After creating the two columns with the properties the binding should be done of those columns to display the data. 

The ways are being shown as:

DataGridTextColumn col1 = new DataGridTextColumn();
col1.Binding = new Binding("name");
DataGridTextColumn col2 = 
new DataGridTextColumn();
col2.Binding = new Binding("age"); 
dataGrid1.Columns.Add(col1);
dataGrid1.Columns.Add(col2);

  • Declare and initialize database connection object with appropriate connection string.
  • Create a DataAdapter and a Dataset object.
  • Using fill method of the DataAdapter object, load the data into the Dataset Object.
  • Change the adapter's SELECT command. 
  • Create the EmpDetail table. 
  • Add both tables to a single dataset. 
  • Display the data using data binding feature of controls like Datagrid or Datalist.

Dim m_adptEmp As SqlDataAdapter:

Private Sub Page_Load(ByVal sender As System.Object, _ByValeAsSystem.EventArgs)HandlesMyBase.Load<BR> DimEmpConnAsNewSqlConnection_<BR> ("server=(local);database=Employees;Trusted_Connection=yes")
     m_adptEmp = New SqlDataAdapter("select * from Emp", EmpConn)
     Dim dsEmp As New DataSet
     m_adptEmp.Fill(dsEmp, "Emp")
     adptEmp.SelectCommand.CommandText = "SELECT * FROM EmpDetail"
     Dim EmpDetail As New DataTable("EmpDetail")
     adptDB.Fill(EmpDetail)
     dsBoth.Tables.Add(Emp)
     dsBoth.Tables.Add(EmpDetail)
     DataGrid1.DataSource = dsEmp.Tables("Emp").DefaultView
     DataGrid1.DataBind()
End Sub

  • The DataGrid that is used contains the provision to have multiple columns to contain the data in an easy and ordered way. 
  • Every column in the multiple columns is having different property of the objects and having collection of items. 
  • The objects are named according to the properties given from get/set properties and the public data field in this case can’t be created. 

The program that shows the creation of multiple columns in DataGrid is as follows:

public struct MyData
{
public string name { set; get; }
public int age { set; get; }
}
dataGrid1.Items.Add(
new MyData(){name="John",age=25});
dataGrid1.Items.Add(
new MyData(){name = "Jill",age = 29 });

  1. The DataGrid control is used to display the fields of the table. It is basically associated with the data source that is present in the column of a table. 
  2. DataGrid provides the access to the rows that allows the control to be taken to the record in the data source. 
  3. DataGrid control provides various features like editing, selection, deleting, paging and sorting. 
  4. DataGrid control allows the user to write the input to bring the output on the web front. It can contain the executable scripts or SQL statements. 
  5. DataGrid control uses the validation server control to validate the data rows and columns of the table.

You cannot specify formatting for columns generated when the grid's AutoGenerateColumns property is set to true, only for bound or template columns. To format, set the column's DataFormatString property to a string-formatting expression suitable for the data type of the data you are formatting.

To display an editable drop-down list it requires:

  1. Template column that is present in the Grid and an object of ItemTemplate that consist of controls like data-bound.
  2. Use of Label controls that produces the current value of the field present in the record. 
  3. Adding of the drop down list takes place by using the object EditItemTemplate. This object adds a column in the template and the property can be customized according to the requirement. 
  4. DropDownList control can be taken from the EditItemTemplate property editor and changes being made into it to represent it on the web front. 
  5. The template column of the drop down list can be added to HTML view.

Similarities:

They are all ASP.NET data Web controls.

They have common properties like: 

  1. DataSource Property
  2. DataBind Method
  3. ItemDataBound
  4. ItemCreated

When the DataSource Property of a Datagrid is assigned to a DataSet then each DataRow present in the DataRow Collection of DataTable is assigned to a corresponding DataGridItem.

Difference:

Datagrid: 

The HTML code generated has an HTML TABLE element created for the particular DataRow and is a tabular representation with Columns and Rows. Datagrid has a in-built support for Sort, Filter and paging the Data. 

Datalist: 

An Array of Rows and based on the Template Selected and the RepeatColumn Property value The number DataSource records that appear per HTML

Repeater Control:

The Datarecords to be displayed depend upon the Templates specified and the only HTML generated accordingly. Repeater does not have in-built support for Sort, Filter and paging the Data.

  • Drop down lists are easy to add on a template column and then added further in HTML view. 
  • There are two tasks involved after populating the drop-down list and they are as follows:
  • Populate the list that is being used by the web application or any application according to the requirement. 
  • Pre-select an appropriate item to be added on the list of drop-down that is just being created. 
  • The drop-down list gets created with the field already being filled and the category being pre-selected from before that has to be displayed in the beginning.

  • The DataSet object is a disconnected storage.
  • It is used for manipulation of relational data. 
  • The DataSet is filled with data from the store
  • We fill it with data fetched from the data store. Once the work is done with the dataset, connection is reestablished and the changes are reflected back into the store.
  • Dataset has a collection of Tables which has DataTable collection which further has DataRow DataColumn objects collections. 
  • It also has collections for the primary keys, constraints, and default values called as constraint collection. 
  • A DefaultView object for each table is used to create a DataView object based on the table, so that the data can be searched, filtered or otherwise manipulated while displaying the data.

For refreshing data in data grid control we can use chasing technique.

The definitive way to determine whether a row has been dirtied is to handle the changed event for the controls in a row. For example, if your grid row contains a TextBox control, you can respond to the control�s TextChanged event. Similarly, for check boxes, you can respond to a Checked Changed event. In the handler for these events, you maintain a list of the rows to be updated. Generally, the best strategy is to track the primary keys of the affected rows. For example, you can maintain an ArrayList object that contains the primary keys of the rows to update.

To copy one row of data, put your cursor in a cell in the grid and press Ctrl+Insert. This will copy the row and its column headers to the clipboard. To copy multiple rows of data, right-click in the grid and choose "Allow multiselect". Use Shift-Click to select multiple adjacent rows, or use Ctrl+Click to select individual, non-adjacent rows. Press Ctrl+C. This will copy all of the rows and their column headers to the clipboard. To copy a single cell's data, turn off "Allow multiselect". Click on the cell you want to copy and press Ctrl+C. 

The following table gives details of what happens with the various copy keys and multi-select options. 

Multi-Select OFF Multi-Select ON 

EDIT COPY CTRL+C CTRL+INS EDIT COPY CTRL+C CTRL+INS 

One Cell Highlighted Cell only Cell only Row plus headings Cell only Cell Only Row plus headings 

Many Cells(rows) highlighted N/A N/A N/A All highlighted rows plus headings All highlighted rows plus headings All highlighted rows plus headings

  • The data grid provides the features on the column which can be sorted, reordered and resized according to the requirements. 
  • The columns can be enabled and disabled by using the column and row properties in the program.

The properties used in this are as follows:

CanUserReorderColumns // this enables or disables the re-ordering of the column
CanUserResizeColumns // this enables or disables the resizing of the column
CanUserResizeRows // this enables or disables the resizing of the row
CanUserSortColumns // this enables or disables the sorting of the row
The program is shown as: 
<DataGrid ItemsSource="{Binding_Products}" 
CanUserReorderColumns="True" CanUserResizeColumns="True" 
CanUserResizeRows="False" CanUserSortColumns="True"/>

After a SELECT query is executed, we must retrieve the rows from the Oracle server to your PC. We do not retrieve the rows all at once, nor do we retrieve them one at a time (unless there is a LONG or LOB column involved). We retrieve the rows in blocks. The number of rows retrieved in each block is the number of rows you specify with "OCI Array Buffer Size".

TOAD defaults to 25 because SQL*Plus defaults to 2@In my opinion, an optimal setting is more like 500 or 10@Here is why: If your dataset has 1,000 rows, and your OCI Array Buffer size is set to 25, then TOAD has to make 40 (that's 1000 / 25) round trips across the network to retrieve all of the rows. So you can immediately see why 500 or 1000 is better. The only disadvantage to a higher setting of OCI Array Buffer Size is that TOAD must allocate memory to hold that many rows prior to each fetch. If that many rows are actually fetched, there is no loss. On the other hand, if not that many rows are retrieved, then we allocated some memory that is not going to be released until the cursor is freed. Luckily, this is a trivial amout of memory, in the grand scheme of things.

Displaying a drop-down list requires a template column in the grid. Typically, the ItemTemplate contains a control such as a data-bound Label control to show the current value of a field in the record. You then add a drop-down list to the EditItemTemplate.

In Visual Studio, you can add a template column in the Property builder for the grid, and then use standard template editing to remove the default TextBox control from the EditItemTemplate and drag a DropDownList control into it instead. Alternatively, you can add the template column in HTML view.

After you have created the template column with the drop-down list in it, there are two tasks. The first is to populate the list. The second is to preselect the appropriate item in the list � for example, if a book�s genre is set to �fiction,� when the drop-down list displays, you often want �fiction� to be preselected.

TOAD 7.5 and up can show nested object type data in popups from the data grids if you are using an 8.0 or higher Oracle client. Right-click on the cell that should contain the data and choose "Popup editor". TOAD 9.0.1 now supports nested object data in its "run as script" function. TOAD versions 7.4 and previous do not support nested object data due to a limitation in their data layer.

  1. DataGrid control has the control over the rows and columns sizes that fits the height and width of the grid. 
  2. AutoGenerateColumns property has to be False to control the column characteristics and it doesn’t let the column to generate automatically. 
  3. The column width can be created using the style element for a particular column. It can also set the width of the element.

The property can be set like:

<asp:BoundColumn DataField="title" SortExpression="title" 
HeaderText="Title">
<ItemStyle Width="100px"></ItemStyle>
</asp:BoundColumn>

  1. The appearance can be controlled by using the attributes and adding them using the programming. 
  2. The tags that can be used are <td> and <tr> tags, that allows the rendering by having the control on the browser and the attributes that are used in this. 
  3. Attributes can be used in the event handler for the OnItemCreated or OnItemDataBound event.
  4. The attribute if need to be added then a TableCell objects need to, be created that represents the cell in DataGrid. 
  5. The DataGridItemEventArgs object is passed to the event handler to be used with the TableCell object and use of AttributeCollection.Add method allow the addition of attributes in the tags.

One way to have columns appear dynamically is to create them at design time, and then to hide or show them as needed. You can do this by setting a columnï's Visible property.

Another one from the list. Herald asked > I changed the font for the DATA Grids, so I could look at Unicode. Now I see the chosen font in the datagrid, but if I open the popup editor it still gives the old font. Is it possible to change this font also, I didn't find it in the options, or could you make the grid popup editor font the same as the data grid font.

After much searching, Brad supplied the following obvious LOL solution :

*Go to View → Toad Options → Editor → Behavior.
*In the Languages section, select "Plain Text" from the dropdown and click the Edit ... button next to the dropdown.
*Go to the Highlighting tab and click the "custom font" button.
*Choose your font and OK your way out.

The Web UI control does not inherently support master-detail data structures. As with other Web server controls, it does not support two-way data binding. If you want to update data, you must write code to do this yourself. You can only edit one row at a time. It does not inherently support sorting, although it raises events you can handle in order to sort the grid contents. You can bind the Web Forms DataGrid to any object that supports the IEnumerable interface.

The Web Forms DataGrid control supports paging. It is easy to customize the appearance and layout of the Web Forms DataGrid control as compared to the Windows Forms one.

The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data.

  1. To add the attribute to <tr> tag fist DataGridItem object is being intitialized. 
  2. DataGridItem represents the row in the DataGrid control and it helps in adding the attribute to the tag. 
  3. The DataGridItemEventArgs object is used to get the DataGridItem object that is passed into the event handler.
  4. The AttributeCollection.Add method is used for DataGridItem object to add the attribute to the <tr> tag that stores the collection of the collection of the GridItem. 
  5. The addition of the attribute to the tag allows it to be represented in the web page or site according to the requirements.

If you want to customize the content of a column, make the column a template column. Template columns work like item templates in the DataList or Repeater control, except that you are defining the layout of a column rather than a row.