| | |
Retrieve EditItemTemplate controls of GridView at code-behind file
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Dec 2008
Posts: 19
Reputation:
Solved Threads: 0
Hi,
I'm trying to access the RangeValidator control at my code-behind file. I keep on getting "Object reference not set to an instance of an object." exception. Can someone enlighten me?
ASPX:
Code behind:
I'm trying to access the RangeValidator control at my code-behind file. I keep on getting "Object reference not set to an instance of an object." exception. Can someone enlighten me?
ASPX:
ASP.NET Syntax (Toggle Plain Text)
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="subject_id" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="5" ForeColor="Black" GridLines="Horizontal" OnDataBound="GridView1_DataBound"> <Columns> <asp:TemplateField HeaderText="Hurdle Weight" SortExpression="hurdle_weight"> <ItemTemplate> <asp:Label ID="Label113" runat="server" Text='<%# Bind("hurdle_weight") %>'></asp:Label> </ItemTemplate> <ItemStyle Wrap="false" /> <EditItemTemplate> <asp:TextBox ID="textbox_hurdleWeight1" Width="30px" runat="server" Text='<%# Bind("hurdle_weight") %>' /> % <asp:RangeValidator ID="RangeValidator16" runat="server" ControlToValidate="textbox_hurdleWeight1" Font-Names="Verdana" ErrorMessage="The hurdle weight must be less or equals with the available weight" Display="Static">* </asp:RangeValidator> </EditItemTemplate> </asp:TemplateField>
Code behind:
ASP.NET Syntax (Toggle Plain Text)
protected void GridView1_Editing(object sender, GridViewEditEventArgs e) { string subjectID = dropdown_subjectCode.SelectedValue.ToString(); int index = Convert.ToInt32(e.NewEditIndex); RangeValidator validator = (RangeValidator)GridView1.Rows[index].NamingContainer.FindControl("RangeValidator16"); validator.MaximumValue = db.getHurdleWeightBalance(subjectID); }
Last edited by dfs3000my; 28 Days Ago at 12:23 pm.
•
•
Join Date: Dec 2008
Posts: 19
Reputation:
Solved Threads: 0
0
#2 28 Days Ago
I have found the workaround for this. More details from here.
ASP.NET Syntax (Toggle Plain Text)
protected void GridViewRowEventHandler(Object sender, GridViewRowEventArgs e) { string subjectID = dropdown_subjectCode.SelectedValue.ToString(); if (e.Row.RowState == DataControlRowState.Edit) { RangeValidator validator = (RangeValidator)e.Row.FindControl("RangeValidator16"); validator.MaximumValue = db.getHurdleWeightBalance(subjectID); } }
![]() |
Similar Threads
- DropDownBox in GridView Edit mode not populating (ASP.NET)
- link to code file (C#)
- error while i am writing the code to file upload (ASP.NET)
- Salesforce.com Custom S-Controls and HTML code Help (Web Development Job Offers)
- How to open a text file from hyperlink in a gridview (C#)
- How to access controls from code behind file (ASP.NET)
- Getting values from GridView Controls (ASP.NET)
- Controls in GridView (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: web browser's Browser_DocumentCompleted event is firing only first time,plz help
- Next Thread: help with datagrid
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos application asp asp.net bc30451 bottomasp.net box browser button c# c#gridviewcolumn checkbox click commonfunctions compatible confirmationcodegeneration content courier css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dynamically edit expose feedback fileuploader fill flash form formatdecimal forms formview gridview gudi homeedition hosting iframe iis javascript jquery listbox login microsoft mono mouse mssql multistepregistration news numerical objects opera panelmasterpagebuttoncontrols parent radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security select silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice xml xsl youareanotmemberofthedebuggerusers





