---
title: "Having trouble showing GridView"  
description: "Having trouble showing GridView"  
author: "Anonymous User"  
published: 2014-02-04  
updated: 2014-02-04  
canonical: https://www.mindstick.com/forum/1950/having-trouble-showing-gridview  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Having trouble showing GridView

Here is my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii)

```
public void gridshow() {        sc.Open();        //int custtid ;        //custtid = (int)cidshow.SelectedItem;        SqlDataAdapter da = new SqlDataAdapter("select Cust_id , Cust_name from Cust_master where Cust_id = '" + cidshow.SelectedItem + "'", sc);        DataSet ds = new DataSet();        da.Fill(ds,"Cust_master");        custshow.DataSource = ds.Tables[0];        sc.Close();    }
```

[Error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) raised is

([Conversion](https://www.mindstick.com/forum/1734/conversion-from-32-bit-integer-to-4-chars) [failed when converting](https://www.mindstick.com/forum/23101/conversion-failed-when-converting-the-nvarchar-value-meetingid-to-data-type-int) the [varchar](https://www.mindstick.com/forum/161878/what-is-the-difference-between-nvarchar-and-varchar) [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) 'System.[Data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science).DataRowView' to data type [int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql).)

## Replies

### Reply by Pravesh Singh

Hi Chintoo,\

If your cidshow is a databound combobox, SelectedItem returns a DataRowView. You will have to extract your ID field from that object

int custtid ;

DateGridView custdgv = cidshow.SelectedItem;

int custtid = Convert.ToInt(custdgv["customerId"]);


---

Original Source: https://www.mindstick.com/forum/1950/having-trouble-showing-gridview

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
