473,395 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

PreRender Error setting textbox width

2
I have a PreRender event to set the width of my textbox when the Edit button is pressed on my grid here is the code:

Private Sub grdPBC_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdPBC.PreRender
If grdPBC.EditItemIndex > -1 Then
Dim tbx As TextBox
tbx = CType(grdPBC.Items(grdPBC.EditItemIndex).Cells(4). Controls(0), TextBox)

tbx.Width = Unit.Pixel(50)
tbx = CType(grdPBC.Items(grdPBC.EditItemIndex).Cells(5). Controls(0), TextBox)
tbx.Width = Unit.Pixel(50)

End If
End Sub
So I bind the data to the grid and when you click on the edit button the width of the two textboxes are 50px. Perfect
But now after I bind the data to the grid I need to add data to one of the colomns, so I use a For Loop to go through the grid and add the data manually
Here is that code:
Dim dgItem As DataGridItem
Dim icount As Integer
Dim dGrandTotal As Double

For Each dgItem In grdPBC.Items

Dim cls As New ClassLibrary1.usp_GetPBCTotalForMonth
cls.Execute(ConfigurationSettings.AppSettings("Con nectionString"), grdPBC.Items(icount).Cells(0).Text, ddMonth.SelectedValue, ddYear.SelectedValue, txtFirstFriday.Text, dGrandTotal)

grdPBC.Items(icount).Cells(4).Text = Format(dGrandTotal, "$##,##0.00")

icount = icount + 1
Next

Again that works fine. But if I now click on the Edit button the PreRender call throws an error on the line:
tbx = CType(grdPBC.Items(grdPBC.EditItemIndex).Cells(4). Controls(0), TextBox)
The error is:
"Run-time exception thrown : System.ArgumentOutOfRangeException - Specified argument was out of the range of valid values. Parameter name: index"

The other textbox in the PreRender event does not produce that error.
Please help.
Thank You
MutlyP
Mar 13 '07 #1
0 1350

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Edward | last post by:
I'm strictly a high-level programmer, so please excuse my ignorance of the inner magic of ASP etc. I have what my company calls a "builder form". It is used to maintain static lookup lists. It...
7
by: scorpion53061 | last post by:
This exception occured while running in the development environment. The debugger didnt catch it though it appeared as a message box prompt........does anyone have insight on this? ...
25
by: Blasting Cap | last post by:
I keep getting errors that pop up when I am trying to convert an application from dotnet framework 1.1 to framework 2.0. The old project was saved in sourcesafe from Visual Studio 2003, and I have...
3
by: dancer | last post by:
I am using Framework 1.1.4322. Who can tell me why I'm getting this error? My code follows Compilation Error Description: An error occurred during the compilation of a resource required to...
3
by: Trez | last post by:
Hey guys, Am new at using ASP.Net. am having some problems updating my SQL DB. whenever i try i get this Error. Can someone help me? Incorrect syntax near 'nvarchar'. Description: An unhandled...
3
by: jc | last post by:
Hello. I have a gridview column item that i want to not make visible if the bound data in that cell is less than a value in a textbox. However, I notice at the time my code checks a function...
4
by: Ty | last post by:
Hello all, I am creating a web site with Visual Stuido 2008. I am trying to use a java script file to create a busybox for login from this page http://blogs.crsw.com/mark/articles/642.aspx. I...
2
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
i'm not sure how the preRender event gets handled. if i have a function: protected void tbPasswordPreRender(object sender, EventArgs e) { tbPswd1.Attributes = tbPswd1.Text; tbPswd2.Attributes...
4
by: Jeff | last post by:
hi asp.net 2.0 I have created a custom web control, here is it's header: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="EditUserBox.ascx.cs" Inherits="Controls_EditUserBox" %> ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.