Solved

asp.net

Posted on 2011-09-20
10
286 Views
Last Modified: 2012-05-12
I have a Grid (telerik rad grid) in my aspx page along with a text box which displays the total number of grid items. I want to be able to update the text in the textbox every time grid refreshes, but the textbox value retains old value even if i assign a new value to the textbox when grid refreshes.
0
Comment
Question by:singsunn
10 Comments
 
LVL 9

Expert Comment

by:BlueYonder
ID: 36568561
The gridview needs a databind.  Here is an example.
gridView.DataSource = theDataSource;
gridView.DataBind();
0
 

Author Comment

by:singsunn
ID: 36568591
I meant i am getting the new count, but when i assign that to the textbox it retains the old value.
0
 
LVL 16

Expert Comment

by:disrupt
ID: 36568834
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:singsunn
ID: 36569448
Thank you for the reply. I might have confused you, the text box is not in the Grid. It is a regular
asp:textbox i added to the page outside the Grid. However i want it to display the count in the grid below it.
0
 
LVL 14

Expert Comment

by:binaryevo
ID: 36569855
in the NeedDataSource event of the grid, you can get a count of your data that your bringing back each time and set your textbox.text value to the count of the data.
0
 

Author Comment

by:singsunn
ID: 36569904
Yes, i do that, but the textbox.text doesn't show the new value.
0
 
LVL 16

Expert Comment

by:disrupt
ID: 36570614
can you provide an example on how you are doing so
0
 

Author Comment

by:singsunn
ID: 36573634
  protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        RadGrid1.MasterTableView.AllowPaging = false;
        RadGrid1.Rebind();
        Textbox1.Text = RadGrid11.MasterTableView.Items.Count.ToString();
       RadGrid1.MasterTableView.AllowPaging = true;
        RadGrid1.Rebind();
    }
Textbox1.Text retains the old value.
0
 
LVL 16

Accepted Solution

by:
disrupt earned 500 total points
ID: 36573763
I would try a recursive find

http://sharpertutorials.com/recursive-findcontrol/

either that or loop through the radgrid like so:

foreach (GridDataItem item in MyRadGrid.MasterTableView.Items)
{
  TextBox txtBox = (TextBox)item.FindControl("Textbox1");
  txtBox.Text = RadGrid11.MasterTableView.Items.Count.ToString();
}
0
 

Author Comment

by:singsunn
ID: 36575205
once again, the text box is not in the grid. It is just something that displays the count of the items in the grid. the aspx page has
<asp:textbox/>
<telerik:radgrid>
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question