Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how we dynamically add control in datagridview control like in a perticular column like textbox and i also want values from database which use these control and also want to to calculate some operation on lostfocus event and it also has a footer row which add perticular column all values.(In windows application only not in web application).
Posted
Updated 19-Mar-10 21:28pm
v3

1 solution

Right Click on GridView select Edit Column.
U will find "Template" , Add Template Field.
In template Field U can Drag Textbox,Button, RadioButton,CheckBox.

For Adding some value/row to Grid, just insert a data into database and rebind the Grid. Below is the code for binding the grid ;) .

C#
public void LoadGrid()
 {
 DataTable dt = new DataTable();
 sqlcon = new SqlConnection(con );
 sqlcon.Open();
 SqlDataAdapter sda = new SqlDataAdapter();
 string strQuery = "select * from employee ";
 SqlCommand cmd = new SqlCommand(strQuery);
 cmd.CommandType = CommandType.Text;
 cmd.Connection = sqlcon;
 sda.SelectCommand = cmd;
 sda.Fill(dt);
 GridView1.DataSource = dt;
 GridView1.DataBind();
 }


Hope this is enough to solve ur problem
 
Share this answer
 
v2

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