Solved

Bind data to BoundFiled of a DetailsView

Posted on 2007-04-05
5
1,189 Views
Last Modified: 2008-01-09
I would like to autopopulate the Password Field and make it only read only on a dataview.

I already have the script to make the password I just need to know how to bind it to the password filed my dataview looks like

  <asp:DetailsView AutoGenerateRows="False" DefaultMode="Insert" DataKeyNames="UserID" DataSourceID="SqlDataSource4"
                                             HeaderText="" ID="DetailsView2" runat="server" Width="275px" >
                                             <Fields>
                                          <asp:BoundField Visible=True DataField="Name" HeaderText="Name" ReadOnly="false" SortExpression="Name" />
                                          <asp:BoundField DataField="EMail" HeaderText="EMail" SortExpression="EMail" />
                                          <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
                                           <asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" />
                                          <asp:CheckBoxField DataField="PrimaryC" HeaderText="Primary" SortExpression="PrimaryC" />
                                          <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
                                        </Fields>
                                      </asp:DetailsView>
0
Comment
Question by:jui2ce
  • 2
5 Comments
 
LVL 27

Expert Comment

by:Sammy
ID: 18862576
if you are getting your data from a database using the SqlDataSource you can use the BoundField property "ReadOnly" like this

 <asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" ReadOnly="True"  />

Good luck
Sammy
0
 

Author Comment

by:jui2ce
ID: 18862596
No the problem is I have a function to Create the password. So before I do the insert I want to fill the password textbox with my random password giving them the option to change it or keep the random password.
0
 
LVL 27

Accepted Solution

by:
Sammy earned 500 total points
ID: 18862633
In that case you can use an item template instead of the BoundField
you can see a walkthru
http://msdn2.microsoft.com/en-us/library/bb288034.aspx
all you need is set a label to hold the password and you can get it by setting the text property of the field to your script "the one generating the password"
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question