470,636 Members | 1,423 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

ASPNET DataGrid Rebind Issue on Serverside formatting

Here is a snippit which replicates my issue. I have a datagrid which contains
an input textbox on each row, binded on the serverside. However it seems that
when I perform a postback to refresh teh numbers, they are not changing due
to the foreach loop I have in this code. When I comment out the foreach loop,
the numbers refresh fine (but the text boxs ovbiously no longer get created).
I have placed this code in the OnItemDataBind method, which the same problem.
I have set the EnableViewState to false on the grid, other then that the
grid has default attributes.

I basically would like to rebind the data upon postback, while keeping the
content in the input text boxes intact.

private void LoadBlotter(System.Web.UI.WebControls.DataGrid oDataGrid)
DataSet oDS = new DataSet();
oDS.ReadXml(new StringReader(@"<NewDataSet>
<ID>Value1</ID><Name> " + System.DateTime.Now.Second.ToString() + @"
<ID>Valie2</ID><Name> " + System.DateTime.Now.Millisecond.ToString() + @"
oDataGrid.DataSource = oDS.Tables[0].DefaultView;
// Apply some special formatting
foreach(DataGridItem e in oDataGrid.Items)
Double dReq = Convert.ToDouble(e.Cells[1].Text);
System.Web.UI.WebControls.TextBox o1ReqTbox = new TextBox();
o1ReqTbox.Text = dReq.ToString("#,##0");
o1ReqTbox.CssClass = "criteriaTableCustom";
o1ReqTbox.ReadOnly = true;

System.Web.UI.WebControls.TextBox ofundedTbox = new TextBox();
ofundedTbox.Attributes.Add("onblur","CalcFunded()" );
ofundedTbox.CssClass = "criteriaTableCustom";

<asp:datagrid EnableViewState=False id=FSummary Runat="server"

Hope ya'll can help
Nov 19 '05 #1
0 1173

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Clayton Hamilton | last post: by
5 posts views Thread by Bill Todd | last post: by
1 post views Thread by pete | last post: by
1 post views Thread by Patrick Delifer | last post: by
4 posts views Thread by Ed Bick | last post: by
1 post views Thread by Korara | last post: by
reply views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.