---
title: "Bind column value to a TextBox"  
description: "Bind column value to a TextBox"  
author: "Anonymous User"  
published: 2013-11-14  
updated: 2013-11-14  
canonical: https://www.mindstick.com/forum/1731/bind-column-value-to-a-textbox  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Bind column value to a TextBox

I would like to bind the [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) returned from a [SQL Query](https://www.mindstick.com/forum/529/rename-table-name-and-column-name-using-sql-query) to a [Text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) Box:

```
 protected void
cmbPujaName_SelectedIndexChanged(object sender, EventArgs e)    {        string pujaselectedid = null;        pujaselectedid = cmbPujaName.DataValueField;        SqlConnection con2 = null;        con2 = new SqlConnection(ConfigurationManager.ConnectionStrings["SRKBSDB"].ConnectionString);        SqlDataAdapter pamt = new SqlDataAdapter("select Amount from PoojaDietyMaster where
PoojaDietyMasterID =" + cmbPujaName.DataValueField, con2);        DataSet pamtds= new DataSet();       
pamt.Fill(pamtds);       
//cmbPujaName.DataSource = pamtds;        txtAmount.Text= pamtds -- Not sure what to add here       
txtAmount.DataBind();    }
```

Please help

## Replies

### Reply by Pravesh Singh

Hi samuel,\
You can try this:

```
SqlCommand c = new SqlCommand("select Amount from
PoojaDietyMaster where PoojaDietyMasterID =" +
cmbPujaName.DataValueField,con2); double c1 =
(double)c.ExecuteScalar();  txtAmount.Text =
c1.ToString();
```

Since you are just getting one value. Theres no need to load it to a Datatable


---

Original Source: https://www.mindstick.com/forum/1731/bind-column-value-to-a-textbox

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
