| | |
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; 22 Days Ago at 12:23 pm.
•
•
Join Date: Dec 2008
Posts: 19
Reputation:
Solved Threads: 0
0
#2 22 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 2.0 3.5 activexcontrol advice ajax appliances asp asp.net beginner bottomasp.net box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class click compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datalist deadlock deployment development dgv dialog dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects opera order problem ratings redirect registration relationaldatabases reportemail rotatepage search security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql ssl tracking treeview validatedate validation vb.net virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment wizard xml xsl





