Solved

Bind data to BoundFiled of a DetailsView

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
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…

744 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

14 Experts available now in Live!

Get 1:1 Help Now