472,783 Members | 953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 software developers and data experts.

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 1256

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Stephen | last post by:
I have got an event below to remove items from an arraylist and then to rebind the arraylist to the datagrid subsequently deleting the appropriate row. My problem is that my code makes sense and I...
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
by: Bill Todd | last post by:
In a WinForms application with a DataGrid bound to a DataTable, if I change the DefaultDataView.Sort property the order of the data in the grid does not change. If I change the Sort property...
by: pete | last post by:
Hello all, I'l displaying a dropdownlist inside a datagrid. The problem comes when I try to get the values the user chose on postback. If I rebind the datagrid, the values of the dropdownlist...
by: Kathy Burke | last post by:
Hi, will try to make this short and clear! (1) I have a list control which is populated by strings as follows (leaving out declarations, etc., for brevity): Dim strListItem As String = "GRN: "...
by: Patrick Delifer | last post by:
HI, I am trying to update a DataGrid where I want to rebind just the row that was updated. Here's the situation: 1) Updating is not a problem, it works fine. 2) I am not using ItemCommand (edit,...
by: RSB | last post by:
Hi Everyone, i am using the following code to transfer a DataGrid to Excel File. Every thing works ok beside the long numerice value like 0000121900000000 gets converted to 1.219E+11. how can i...
by: Ed Bick | last post by:
I know how to do this stuff so easily in VB6......... 3 questions. I have loaded a grid by binding it to a dataset. All is well with that. 1) How do I retrieve the value of a column when a...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.