This is a migrated thread and some comments may be shown as answers.

Problem whit adding New row whit code.

0 Answers 52 Views
GridView
This is a migrated thread and some comments may be shown as answers.
HamiD Mayeli
Top achievements
Rank 1
HamiD Mayeli asked on 16 Oct 2009, 06:47 PM
Hello

I`m Using 2 DataGrid (Master/Detail) and wanna add new row in both of them, so i`m wrote on button Click event this code.

// Adding Row On Master  
GridHdr.Rows.AddNew(GridHdr.Rows.NewRow());  
// If new row is first row current row being null then i`m changing it.  
if (GridHdr.CurrentRow == null)  
   GridHdr.CurrentRow = GridHdr.Rows[0];  
// Filling Hdr Primerykey  
GridHdr.CurrentRow.Cells["pkID"].Value = HdrID;  
GridItm.Rows.AddNew(GridItm.Rows.NewRow());  
// On DetailGrid current row, if is first row thats not null  
if (GridItm.Row.Count == 1)  
   GridItm.CurrentRow = GridItm.Rows[0];  
// Filling Itm PrimeryKey  
GridItm.CurrentRow.Cells["pkID"].Value = ItmID;  
// Filling Itm FKey  
GridItm.CurrentRow.Cells["fkHdrID"].Value = HdrID; 
 but when button Click event was end, GridItm.Rows.Cells["pkID"].Value and other Cells has not value.
and when GridItm lost focus Itm new row lost, because has not fkHdrID (it`s Relation) Value.

Regards.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
HamiD Mayeli
Top achievements
Rank 1
Share this question
or