hello All,

i have following problem with datagrid,

I have windows datagrid. I have one custom tablestyle applied to it.I
have delete funtionality on this datagrid that when user select row
by

clicking on the rowheader and pressing delete on keyboard. I have
confirmation over delete key press to ask user whether to delete or
not

row. Now the problem is when i select any row and press delete button
i can see the popup and if user clcks "No" here i am rebinding the
grid with same datasource but after rebinding if i click on the next
row the content in the first column of previously selected row for
which we have done delete get vanished.

I have 2 observations

1) If we have datagrid with all above functionality but without
tablestyle the problem never happen.
2) As we add tablestyle into it problem will be there.

//C# code For without tablestyle.
private void Form1_Load(object sender, System.EventArgs e)
{
for(int i=0;i<2;i++)
{
if(i==0)
{
DataColumn dc=new DataColumn();
dc.Caption="Name";
dc.ColumnName="Name";
dc.MaxLength=50;
dt.Columns.Add(dc);
}
else
{
DataColumn dc=new DataColumn();
dc.Caption="Age";
dc.ColumnName="Age";
dc.MaxLength=50;
dt.Columns.Add(dc);
}
}
createRow();
//myGrid1.TableStyles.Add(AddTableStyle());
myGrid1.DataSource=dt;

}

private void createRow()
{
DataRow dr=dt.NewRow();
dr[0]="Ashish";
dr[1]="25";
dt.Rows.Add(dr);

DataRow dr1=dt.NewRow();
dr1[0]="Tee";
dr1[1]="25";
dt.Rows.Add(dr1);

DataRow dr2=dt.NewRow();
dr2[0]="Helllo";
dr2[1]="25";
dt.Rows.Add(dr2);
}

private void myGrid1_RowDelete()
{
MessageBox.Show("You can't delete this row");
myGrid1.DataSource=null;
myGrid1.DataSource=dt;
}

private DataGridTableStyle AddTableStyle()
{
DataGridTableStyle ts=new DataGridTableStyle();
ts.MappingName=dt.TableName.ToString();
for(int y=0;y<dt.Columns.Count;y++)
{
DataGridTextBoxColumn col=new DataGridTextBoxColumn();
col.MappingName = dt.Columns[y].ColumnName;
col.HeaderText = dt.Columns[y].ColumnName;
col.Width = 150;
col.TextBox.MaxLength=50;
ts.GridColumnStyles.Add(col);
}
return ts;;
}

//C# code with tablestyle

private void Form1_Load(object sender, System.EventArgs e)
{
for(int i=0;i<2;i++)
{
if(i==0)
{
DataColumn dc=new DataColumn();
dc.Caption="Name";
dc.ColumnName="Name";
dc.MaxLength=50;
dt.Columns.Add(dc);
}
else
{
DataColumn dc=new DataColumn();
dc.Caption="Age";
dc.ColumnName="Age";
dc.MaxLength=50;
dt.Columns.Add(dc);
}
}
createRow();
myGrid1.TableStyles.Add(AddTableStyle());
myGrid1.DataSource=dt;

}

private void createRow()
{
DataRow dr=dt.NewRow();
dr[0]="Ashish";
dr[1]="25";
dt.Rows.Add(dr);

DataRow dr1=dt.NewRow();
dr1[0]="Tee";
dr1[1]="25";
dt.Rows.Add(dr1);

DataRow dr2=dt.NewRow();
dr2[0]="Helllo";
dr2[1]="25";
dt.Rows.Add(dr2);
}

private void myGrid1_RowDelete()
{
MessageBox.Show("You can't delete this row");
myGrid1.DataSource=null;
myGrid1.DataSource=dt;
}

private DataGridTableStyle AddTableStyle()
{
DataGridTableStyle ts=new DataGridTableStyle();
ts.MappingName=dt.TableName.ToString();
for(int y=0;y<dt.Columns.Count;y++)
{
DataGridTextBoxColumn col=new DataGridTextBoxColumn();
col.MappingName = dt.Columns[y].ColumnName;
col.HeaderText = dt.Columns[y].ColumnName;
col.Width = 150;
col.TextBox.MaxLength=50;
ts.GridColumnStyles.Add(col);
}
return ts;;
}


How can i i prevent value to be vanished in datagrid with tablestyle.