How to edit Dataset value (NOT DATA GRID)
-
Hi All, i want to edit DataSet value before binding to GridView. How can i do that..? conn.open(); string result="select name,address,age"; sqlCommand cmnd=new sqlCommand(result); sqlDataAdapter ad=new sqlDataAdapter(result,conn); DataSet ds=new DataSet(); result.Connection=conn; ad.SelectCommand=result; // in here i want to edit (divide age value by 2) before bind data to gridview. ad.fill(ds); GridView1.DataSource=ds; GridView1.DataBind(); conn.close(); i want to divide age value by 2 before bind data to gridview.How can i do that...??? Thank you very much .....
CheeN
-
Hi All, i want to edit DataSet value before binding to GridView. How can i do that..? conn.open(); string result="select name,address,age"; sqlCommand cmnd=new sqlCommand(result); sqlDataAdapter ad=new sqlDataAdapter(result,conn); DataSet ds=new DataSet(); result.Connection=conn; ad.SelectCommand=result; // in here i want to edit (divide age value by 2) before bind data to gridview. ad.fill(ds); GridView1.DataSource=ds; GridView1.DataBind(); conn.close(); i want to divide age value by 2 before bind data to gridview.How can i do that...??? Thank you very much .....
CheeN
-
Hi All, i want to edit DataSet value before binding to GridView. How can i do that..? conn.open(); string result="select name,address,age"; sqlCommand cmnd=new sqlCommand(result); sqlDataAdapter ad=new sqlDataAdapter(result,conn); DataSet ds=new DataSet(); result.Connection=conn; ad.SelectCommand=result; // in here i want to edit (divide age value by 2) before bind data to gridview. ad.fill(ds); GridView1.DataSource=ds; GridView1.DataBind(); conn.close(); i want to divide age value by 2 before bind data to gridview.How can i do that...??? Thank you very much .....
CheeN
You can create new coloum that age value is divied by 2, and delete the old age column and set the new column's name to "age"
-
would it be ok to do it with you sql statement. In that case you could do: Select name, adress, age / 2 as age from [yourdbname]
Thank you for you reply .....But i had a problem when i going to DataBind. this is the error.. GridView1.DataBind(); //------ error - A field or property with the name 'age' was not found on the selected data. But i correctly configured on GridView1.I use a BoundField to view this 'age' with DataField='age'on my GridView1 control.. Why i got this error..????
CheeN
-
Thank you for you reply .....But i had a problem when i going to DataBind. this is the error.. GridView1.DataBind(); //------ error - A field or property with the name 'age' was not found on the selected data. But i correctly configured on GridView1.I use a BoundField to view this 'age' with DataField='age'on my GridView1 control.. Why i got this error..????
CheeN
-
You can create new coloum that age value is divied by 2, and delete the old age column and set the new column's name to "age"
-
Hi All, i want to edit DataSet value before binding to GridView. How can i do that..? conn.open(); string result="select name,address,age"; sqlCommand cmnd=new sqlCommand(result); sqlDataAdapter ad=new sqlDataAdapter(result,conn); DataSet ds=new DataSet(); result.Connection=conn; ad.SelectCommand=result; // in here i want to edit (divide age value by 2) before bind data to gridview. ad.fill(ds); GridView1.DataSource=ds; GridView1.DataBind(); conn.close(); i want to divide age value by 2 before bind data to gridview.How can i do that...??? Thank you very much .....
CheeN
You can change it very easily suppose you have the dataset ds Then ds.Tables[0].rows[2].columns[2]="Your New Value"; Thank you
Vinod Kumar Prajapati Software Engineer EBC Publishing Pvt. Ltd.