I am experiencing a problem about the postback logic on RadGrid.
I dynamically create and send columns to the RadGrid object. I put RadTextBoxes in the grid, and fill them with information. I also name the RadTextBoxes and I am able to reach themusing this code:
foreach (GridDataItem dataItem in grdSource.MasterTableView.Items)
{
if (dataItem.ItemType == GridItemType.Item)
{
foreach (GridTemplateColumn column in grdSource.Columns)
{
RadTextBox txtField = (RadTextBox)dataItem.FindControl("txtColumnName");
if (txtField != null)
txtField.Text =/* Stuff I will do */;
}
}
}
This code works well, if I run it right after I fill the grid.
But here is the problem: After all these done, I change something on the textbox, then I click some button and do a postback, If I put the same code to the click event of the button, then this code doesn't work. And my RadGrid lost all its data.
What should I do?
I dynamically create and send columns to the RadGrid object. I put RadTextBoxes in the grid, and fill them with information. I also name the RadTextBoxes and I am able to reach themusing this code:
foreach (GridDataItem dataItem in grdSource.MasterTableView.Items)
{
if (dataItem.ItemType == GridItemType.Item)
{
foreach (GridTemplateColumn column in grdSource.Columns)
{
RadTextBox txtField = (RadTextBox)dataItem.FindControl("txtColumnName");
if (txtField != null)
txtField.Text =/* Stuff I will do */;
}
}
}
This code works well, if I run it right after I fill the grid.
But here is the problem: After all these done, I change something on the textbox, then I click some button and do a postback, If I put the same code to the click event of the button, then this code doesn't work. And my RadGrid lost all its data.
What should I do?