Accessing Datagrid selected row cell value (c# .NET)
Expand Post »
Hi all!
I would like some help for getting a value out of a selected row of a datagrid.
To do this i used the following code but it returns an empty string
(DG is my datagrid)
string val = DG.SelectedItem.Cells[1].Text;
Response.Write("*"+val+");
The rouput of this its: **
although there is a value on the cell.
The datagrid is created and filled in the Page_Load when !Page.IsPostBack and the above code is called when a button is pressed.
Re: Accessing Datagrid selected row cell value (c# .NET)
No unfortunately its not this. I have tried to display something using all the indexes but it doesn work.
In the select event I have also tried using:
e.Item.Cells[1].Text; and yet again its displayed empy.
Any ideas?
Re: Accessing Datagrid selected row cell value (c# .NET)
Hi...
Try This may this will work
int Rowcount = dgTicket.Rows.Count ;
this.dgTicket.Rows[Rowcount].Cells[1].Text;// add the array item of //which column do u want the text
just add this two lines of code may this will work it out..
hi spoorti you can insert the values into into data grid by simple sql command...there are multiple ways to insert the values
simple one is to bind the datasource.
can u show me the exact code what u have written for that i can help you...
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.