Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

need introduced value in detailsview in code-behind

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bob - 22 Apr 2008 20:36 GMT
Hi,

the detailsview (default mode = insert) is used to introduce names into the
database.
I need in code-behind the introduced name. I tried this:

<asp:DetailsView ID="DetailsView1" runat="server" DefaultMode="Insert" >
<Fields>
<asp:BoundField DataField="name" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>

code-behind:
-------------
Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.DataBound
dim lol as string
lol = DetailsView1.Rows(0).Cells(1).Text
Response.Write(lol)

End Sub

but this gives nothing.

Ant idea how to get the introduced name in code-behind?
Thanks
Bob
Manish - 23 Apr 2008 15:26 GMT
Hi bob,

I m not able to repplicate the issue. I am getting the desired output. I
tried the same code that you are using. Please find my aspx page.

<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataKeyNames="CategoryID"
           DataSourceID="SqlDataSource1" Height="50px" Style="position:
static" Width="125px">
           <Fields>
               <asp:BoundField DataField="CategoryID"
HeaderText="CategoryID" InsertVisible="False"
                   ReadOnly="True" SortExpression="CategoryID" />
               <asp:BoundField DataField="CategoryName"
HeaderText="CategoryName" SortExpression="CategoryName" />
               <asp:BoundField DataField="Description"
HeaderText="Description" SortExpression="Description" />
               <asp:CommandField ShowInsertButton="True" />
           </Fields>
       </asp:DetailsView>

Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.DataBound
       Dim lol As String
       lol = DetailsView1.Rows(0).Cells(1).Text
       Response.Write(lol)
   End Sub

I am getting the text from the 1st column in row 0.

Regards,
Manish
www.ComponentOne.com

> Hi,
>
[quoted text clipped - 24 lines]
> Thanks
> Bob
Chris - 24 Apr 2008 10:32 GMT
Thanks for replying, but i still get nothing.
What do you get?

i tried this: DetailsView1.Rows(0).Cells(0).Text
but this gives me the headertext ("name") of the field and not the entered
value.

What i want is what the user types into the textbox embedded into the
detailsview.
But now i was thinking: is it not to early to use DetailsView1_DataBound,
because at that stage, nothing is entered into the textbox of the
detailsview?

???

> Hi bob,
>
[quoted text clipped - 59 lines]
>> Thanks
>> Bob

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.