hi there,
how can i add add a row to the bottom of the datagrid view in C#??
thanxx
hi there,
how can i add add a row to the bottom of the datagrid view in C#??
thanxx
You need to use an Order By clause
hi there,
how can i add add a row to the bottom of the datagrid view in C#??
thanxx
You need to use an Order By clause
i didn't mean that.like this dgvDAction.Rows.Insert(0, 1+ r);
how can i add a row to the bottom of the datagrid view???
I would base your datagridview.sourcedate on a dataTable object. Then you can apply a dataview control to the table for sorting. Then set the datagridview.sourcedata to the dataview control and sort the dataview by the unique rowID field (you will need a unique rowID field field for this to work or a combination of fields to make up some kind of key to sort on).
i didn't mean that.like this dgvDAction.Rows.Insert(0, 1+ r);
how can i add a row to the bottom of the datagrid view???
I would base your datagridview.sourcedate on a dataTable object. Then you can apply a dataview control to the table for sorting. Then set the datagridview.sourcedata to the dataview control and sort the dataview by the unique rowID field (you will need a unique rowID field field for this to work or a combination of fields to make up some kind of key to sort on).
can u explain more???
String query = @"Select TActionDes,TAssignTo,TDueDate,TStatus,TDateComplete,TComment from TopicAction Where TopicNo=@topicno and Phase=@phase Order by TActionDes DESC";
SqlCommand command = new SqlCommand(query, DB.getConnection());
command.Parameters.Add("@topicno", SqlDbType.VarChar).Value = tno;
command.Parameters.Add("@phase", SqlDbType.Int).Value = phase;
// DataGridViewCheckBoxColumn checkbox = (DataGridViewCheckBoxColumn)dgvDAction.Rows[0].Cells[3].OwningColumn;
SqlDataAdapter da = new SqlDataAdapter(command);
DataTable dt = new DataTable();
da.Fill(dt);
for ( int r = 0; r < dt.Rows.Count; r++)
{
dgvDAction.Rows.Insert(0, 1 + r);
dgvDAction.Rows[r].Cells[0].Value = dt.Rows[r]["TActionDes"].ToString();
dgvDAction.Rows[r].Cells[1].Value = dt.Rows[r]["TAssignTo"].ToString();
dgvDAction.Rows[r].Cells[2].Value = dt.Rows[r]["TDueDate"].ToString();
dgvDAction.Rows[r].Cells[3].Value = dt.Rows[r]["TStatus"].ToString();
dgvDAction.Rows[r].Cells[4].Value = dt.Rows[r]["TDateComplete"].ToString();
dgvDAction.Rows[r].Cells[5].Value = dt.Rows[r]["TComment"].ToString();
}
db10.closeConnection();
is the above code correct????
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.