Solved

Bind data to BoundFiled of a DetailsView

Posted on 2007-04-05
5
1,191 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 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