TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
dc
NA
663
0
problem; obtain value in detailsview cells
Nov 14 2011 6:06 PM
Can you tell me why I can not access the value of a textbox in the detailsview control?
I am working on a new C# asp.net 2010 webforms application. I am trying to obtain the value loaded into a textbox(cell) for a detailsview control. When I step through the code, the debugger says the value is NULL. However when I run new the web page, there is the correct value loaded into the cell(textbox).
When I am trying to access the cell, I am clicking on a button that is not inside of the detailsview control. This is the requestor's preference. If I need to use only the buttons in the detailsview control, please let me know and how would you code it?
The following is the code I have right now:
<%@ Page Language="C#" MasterPageFile="~/RpApp.Master" AutoEventWireup="true"
CodeBehind="Detail.aspx.cs" Inherits="Support.Att_Detail" %>
<asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="Support.AttDataContext"
Select="new (Att_id, Prior_Cutoff_Date)"
TableName="Attestations" Where="Att_id == @Attid">
<WhereParameters>
<asp:SessionParameter Name="Att_id" SessionField="AttID" Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" EnableModelValidation="True"
AutoGenerateRows="False" DataSourceID="LinqDataSource1" BorderStyle="Solid" HorizontalAlign="Center">
<Fields>
<asp:TemplateField HeaderText="Att ID">
<ItemTemplate>
<asp:TextBox ID="TextBoxAttid" runat="server" Text='<%# Eval("Att_id") %>'
BorderStyle="None"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Prior Cutoff Date" >
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Prior_Cutoff_Date") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Prior_Cutoff_Date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
<asp:Button
ID="btnNext"
Text="NEXT"
runat="server"
onClick="NextButton"
CssClass="RptFormButton" />
--------
The following is the code in the aspx.cs file
protected void NextButton(object sender, EventArgs e)
{
TextBox tb = (TextBox)DetailsView1.FindControl("TextBox1.Text");
string name = DetailsView1.Rows[0].Cells[1];
}
Reply
Answers (
1
)
Deallocation memory
Dll to Handle Request in ASP.NET