Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Sir,


I want to set value of textbox control of datagrdiview selected row .

What I have tried:

Here,is my code which i have tried,but it's return old value.Will you,please suggest be what I am doing wrong.

Suppose variable s contains selected row index

dGvInvoice.Rows[s].Cells[2].Value = txtChallanNo.Text.Trim();

Thanks in Advance
Posted
Updated 17-Mar-17 5:53am
Comments
Karthik_Mahalingam 15-Mar-17 8:42am    
Not Clear, Use Improve question to add more info to the question.
CHill60 15-Mar-17 8:50am    
"return old value" ... old value of TextBox or old value of DataGridView cell?
Where are you putting this code?
priyanka456 15-Mar-17 8:53am    
I want to set value of textbox in datagridview selected row on button click(present outside datagrdiview)
CHill60 15-Mar-17 10:11am    
And that is what your code is doing at first glance. You didn't answer my question about "old value". What is actually happening with your code

1 solution

Please check Data Source binding of DataGrid.

Datareader source will read in readonly feedforward type dataset no changes will save.

DataAdapator should have updatable binding, and you need to update Datagrid data back to database else changes will lost.

Simple solution is update database and refresh DataGrid
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900