Solved

Bind data to BoundFiled of a DetailsView

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending E-mail ASP.Net 3 56
Code works but I need to redo it and assign values to Model 7 32
ADO.NET ENTITY DATA MODEL 3 30
Replace &lt; with < 14 54
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now