This is a migrated thread and some comments may be shown as answers.

Set Value and Text members from DataSource in Bound RadGrid

2 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 1
Bruno asked on 05 Aug 2011, 01:24 PM
Hi

How can I Set Value and Text members from DataSource in Bound RadGrid?

The code:
const string sSql = "SPl_JUIZOS";
SqlConnection oConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
SqlDataAdapter oAdapter = new SqlDataAdapter(sSql, oConnection);
DataTable oDataTable = new DataTable();
 
 
GridJuizos.DataSource = oDataTable;


Tks

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 05 Aug 2011, 01:34 PM
Hello Bruno,

Try the following code snippet to set value for GridBoundColumn.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
      if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem dataItem = (GridEditableItem)e.Item;
            TextBox txt = dataItem["UniqueName"].Controls[0] as TextBox;
            txt.Text = "Your text";
        }
}

Thanks,
Shinu.
0
Bruno
Top achievements
Rank 1
answered on 05 Aug 2011, 01:41 PM
Shinu, tks for your reply...

what I need is to have each row of the RadGrid with a text (the description field from the DB) and a value associated (the id from the DB).

Tks
Tags
Grid
Asked by
Bruno
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bruno
Top achievements
Rank 1
Share this question
or