| | |
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; 20 Days Ago at 12:23 pm.
•
•
Join Date: Dec 2008
Posts: 19
Reputation:
Solved Threads: 0
0
#2 20 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 3.5 ajax alltypeofvideos appliances asp asp.net bc30451 beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions control countryselector dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iis javascript list listbox login microsoft mouse mssql nameisnotdeclared news novell numerical opera panelmasterpagebuttoncontrols problem radio redirect registration relationaldatabases reportemail save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visualstudio vs2008 web webapplications webdevelopemnt webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers





