473,785 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checkboxlist inside a formview databind with objectdatasourc e

Jai
Hi,

Somebody please tell me how to bind(two way) a checkboxlist with
objectdatasourc e if the checkboxlist is inside a formview.....

Code of FormView is like this::---

<asp:FormView ID="FormView1" runat="server"
DataSourceID="O bjectDataSource 1">
<EditItemTempla te>
<table border="0" cellpadding="0" cellspacing="0"
style="width: 100%">
<tr>
<td align="left" style="width:
100px; height: 16px;">
<asp:Label ID="lblUserName "
runat="server" AssociatedContr olID="lblEditUs erName" Text="User Name:"

Width="100px"></asp:Label></td>
<td align="left" style="width:
100px; height: 16px;">
<asp:Label
ID="lblEditUser Name" runat="server" Text='<%# Eval("UserName" )
%>'></asp:Label></td>
<td align="left" style="width:
100px; height: 16px;">
</td>
</tr>
<tr>
<td align="left" style="width:
100px">
<asp:Label
ID="lblFirstNam e" runat="server" AssociatedContr olID="FirstName "
Text="First Name:"
Width="57px"></asp:Label></td>
<td align="left" style="width:
98px">
<asp:TextBox ID="FirstName"
runat="server" Text='<%# Bind("FirstName ") %>'
CssClass="textb ox"></asp:TextBox></td>
<td align="left" style="width:
100px">
</td>
</tr>
<tr>
<td align="left" style="width:
100px">
<asp:Label ID="lblLastName "
runat="server" AssociatedContr olID="LastName" Text="Last Name:"

Width="57px"></asp:Label></td>
<td align="left" style="width:
98px">
<asp:TextBox ID="LastName"
runat="server" Text='<%# Bind("LastName" ) %>'
CssClass="textb ox"></asp:TextBox></td>
<td align="left" style="width:
100px">
</td>
</tr>
<tr>
<td align="left" style="width:
100px">
<asp:Label ID="lblEmail"
runat="server" AssociatedContr olID="Email" Text="Email:"

Width="57px"></asp:Label></td>
<td align="left" style="width:
98px">
<asp:TextBox ID="Email"
runat="server" Text='<%# Bind("Email") %>'
CssClass="textb ox"></asp:TextBox>
<asp:RequiredFi eldValidator
ID="EmailRequir ed" runat="server" ControlToValida te="Email"
Display="Dynami c" ErrorMessage="E mail
is a required field."
ValidationGroup ="modifyProfile ">*</asp:RequiredFie ldValidator>
<asp:RegularExp ressionValidato r
ID="EmailFormat " runat="server" ControlToValida te="Email"
Display="Dynami c" ErrorMessage="T he
email format is invalid." ValidationExpre ssion="\S+@\S+\ .\S+"

ValidationGroup ="modifyProfile ">*</asp:RegularExpr essionValidator ></td>
<td align="left" style="width:
100px">
</td>
</tr>
<tr>
<td align="left" style="width: 100px">
<asp:Label ID="lblEditOccu pation"
runat="server" AssociatedContr olID="cbEditOcc upation"
Text="Occupatio n"></asp:Label></td>
<td align="left" style="width: 98px">
<asp:CheckBoxLi st ID="cbEditOccup ation"
runat="server" AppendDataBound Items="true" DataTextField=' <%#
Bind("Occupatio n") %>'
DataValueField= '<%#
Bind("Occupatio n") %>' RepeatColumns=" 2" RepeatDirection ="Horizontal ">

<asp:ListItem>S hopkeeper</asp:ListItem>

<asp:ListItem>P ublisher</asp:ListItem>

<asp:ListItem>T eacher</asp:ListItem>

<asp:ListItem>S cientist</asp:ListItem>
</asp:CheckBoxLis t></td>
<td align="left" style="width: 100px">
</td>
</tr>

<tr>
<td align="left" style="width: 100px">
</td>
<td align="left" style="width: 100px">
<asp:Validation Summary
ID="ValidationS ummary1" runat="server" DisplayMode="Li st"
ValidationGroup ="modifyProfile " />
<asp:ImageButto n ID="btnUpdate"
runat="server" CommandName="Up date"
SkinID="save" ToolTip="Save"
ValidationGroup ="modifyProfile " />
<asp:ImageButto n ID="btnCancel"
runat="server" CausesValidatio n="False" CommandName="Ca ncel"
SkinID="cancel" ToolTip="Cancel " />

</td>
</tr>
</table>
</EditItemTemplat e>
<ItemTemplate >
<table border="0" cellpadding="0" cellspacing="0"
style="width: 100%">
<tr>
<td align="left"
style="width: 100px; height: 16px;">
<asp:Label
ID="lblUserName " runat="server" AssociatedContr olID="UserNameL abel"
Text="User Name:"

Width="100px"></asp:Label></td>
<td align="left"
style="width: 100px; height: 16px;">
<asp:Label
ID="UserNameLab el" runat="server" Text='<%# Bind("UserName" )
%>'></asp:Label></td>
<td align="left"
style="width: 100px; height: 16px;">
</td>
</tr>
<tr>
<td align="left"
style="width: 100px">
<asp:Label
ID="lblFirstNam e" runat="server" AssociatedContr olID="FirstName Label"
Text="First Name:"
Width="57px"></asp:Label></td>
<td align="left"
style="width: 100px">
<asp:Label
ID="FirstNameLa bel" runat="server" Text='<%# Bind("FirstName ")
%>'></asp:Label></td>
<td align="left"
style="width: 100px">
</td>
</tr>
<tr>
<td align="left"
style="width: 100px">
<asp:Label
ID="lblLastName " runat="server" AssociatedContr olID="LastNameL abel"
Text="Last Name:"

Width="57px"></asp:Label></td>
<td align="left"
style="width: 100px">
<asp:Label
ID="LastNameLab el" runat="server" Text='<%# Bind("LastName" )
%>'></asp:Label></td>
<td align="left"
style="width: 100px">
</td>
</tr>
<tr>
<td align="left"
style="width: 100px">
<asp:Label
ID="lblEmail" runat="server" AssociatedContr olID="EmailLabe l"
Text="Email:"

Width="57px"></asp:Label></td>
<td align="left"
style="width: 100px">
<asp:Label
ID="EmailLabel " runat="server" Text='<%# Bind("Email")
%>'></asp:Label></td>
<td align="left"
style="width: 100px">
</td>
</tr>
<tr>
<td align="left" style="width: 100px">
<asp:Label ID="lblOccupati on"
runat="server" AssociatedContr olID="cbOccupat ion"
Text="Occupatio n"></asp:Label></td>
<td align="left" style="width: 100px">
<asp:CheckBoxLi st ID="cbOccupatio n"
runat="server" DataSourceID="O bjectDataSource 1"
AppendDataBound Items="true" DataTextField=' <%# Bind("Occupatio n") %>'
DataValueField= '<%# Bind("Occupatio n") %>'
RepeatColumns=" 2"
RepeatDirection ="Horizontal " Enabled="false" >

<asp:ListItem>S hopkeeper</asp:ListItem>

<asp:ListItem>P ublisher</asp:ListItem>

<asp:ListItem>T eacher</asp:ListItem>

<asp:ListItem>S cientist</asp:ListItem>
</asp:CheckBoxLis t></td>
<td align="left" style="width: 100px">
</td>
</tr>

<tr>
<td align="left" style="width: 100px">
</td>
<td align="left" style="width: 100px">
<asp:ImageButto n ID="btnEdit"
runat="server" CausesValidatio n="False" CommandName="Ed it"
SkinID="edit" ToolTip="Edit" />

</td>
</tr>
</table>
</ItemTemplate>
</asp:FormView>

<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
SelectMethod="G etUser"
TypeName="Membe rship.Membershi pManager"
UpdateMethod="E ditUser">
<UpdateParamete rs>
<asp:Paramete r Name="UserName" Type="String" />
<asp:Paramete r Name="FirstName " Type="String" />
<asp:Paramete r Name="Email" Type="String" />
<asp:Paramete r Name="LastName" Type="String" />
<asp:Paramete r Name="Occupatio n" Type="String" />
</UpdateParameter s>
<SelectParamete rs>
<asp:ProfilePar ameter Name="UserName"
PropertyName="U serName" Type="String" />
</SelectParameter s>
</asp:ObjectDataS ource>

SourceCode:---------

Public Shared Function GetUser(ByVal UserName As String) As SiteUser

Dim p As SiteUser =
ProfileManager. GetUserProfileI nfo(UserName)
Dim user As MembershipUser =
System.Web.Secu rity.Membership .GetUser(UserNa me)

If Not (p Is Nothing) Then

If Not (p Is Nothing) Then
Return New SiteUser(p.User Name, p.FirstName,
p.LastName, p.Occupation, p.Password, p.Email, p.Question, p.Answer)
Else
Return New SiteUser(p.User Name, "", "", "", "", "",
"", "")
End If
End If

AND

Public Shared Function EditUser(ByVal UserName As String, ByVal
IsApproved As Boolean, ByVal FirstName As String, ByVal Email As
String, ByVal LastName As String, ByVal Occupation As String) As
Integer

Dim ErrorMessage As Integer = 0 'No Errors
Dim user As MembershipUser =
System.Web.Secu rity.Membership .GetUser(UserNa me)
If Not IsNothing(user) Then
user.Email = Email
user.IsApproved = IsApproved
Try
System.Web.Secu rity.Membership .UpdateUser(use r)
ProfileManager. UpdateUserProfi leInfo(UserName ,
FirstName, LastName, Occupation)
Catch ex As Exception
ErrorMessage = 2 'Error updating user information
End Try
Else
ErrorMessage = 1 'Error finding user
End If

Return ErrorMessage

End Function

Return Nothing
End Function

One more thing is that this details are storing in the aspnet_profile
table.I had declared this occupation as:--
<properties>
<add name="FirstName " type="string"/>
<add name="LastName" type="string"/>
<add name="Occupatio n" type="string"/>
</properties>
</profile>

Please help me how can i show this checkboxlist value from the profile
table and also update or insert in the profile through
checkboxlist(ch eckboxlist is inside a formview)

Please...Please help me....

Thanks in advance.....

Sep 24 '06 #1
0 2178

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4043
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to work:( Thanks My CheckBoxList in the DataList Below
5
2199
by: Jurgen Appelo | last post by:
I'm at a loss here... My FormView control automatically performs a databind at each postback on the server. But in some cases I don't want this to happen. Like when the business layer decides that some of the information in the controls cannot be accepted. But then the FormView binds to the datasource again, and the input in all contols is lost. And the user will have to type it all over again. In ASP.NET 1.1 we could simply say: If Not...
3
3434
by: Jurgen Appelo | last post by:
I asked this question earlier, but unfortunately the two replies I got did not solve the problem. Here it is again, but now with the code: After an Update my FormView always loses its viewstate values. The field values in the FormView are always overwritten by the results of the Update method in the business layer. No matter what I do, the databind always takes place, even when I don't want it to. See the example below. This is a...
4
12917
by: J055 | last post by:
Hi I thought I was trying to do something very simple but I'm have a lot of trouble trying to do the following. <asp:FormView ID="fvGroups" runat="server" DataKeyNames="GroupID" DataSourceID="odsGroups" DefaultMode="Insert" Visible="false" OnItemCommand="fvGroups_ItemCommand"> <InsertItemTemplate> <asp:DropDownList ID="ddlEditMode" runat="server"
0
2418
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1"> <EditItemTemplate>
0
4749
by: ThePurpleCat | last post by:
Hi, I'm a newbie to ASP.NET programming but not to Visual Studio. I'm having trouble getting my Master-Details page to work. I have a page enabled GridView which is linked to a FormView control through an objectdatasource. The paging on my GridView works fine except that when I change the page the FormView does not update. I tried setting the selectedindex to 0 in the GridView's PageIndexChanged event and manually binding the formview...
0
1995
by: =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?= | last post by:
Hello, I read some msdn and other articles about how does databinding among DataSource controls and FormView / GridView controls works but I still don't fully understand to this blackbox. I have few questions and hopefully you can provide me some answers. 1. Best place for DataBinding. Where is the best place for calling DataBind method? Is it possible to say don't bind controls for this postback and use current values instead? These...
5
4681
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a SelectParameters with a SessionParameter in the parameters collection and the object stored in the Session is a reference type, the DataGrid fails to enter Line Editing mode. Is this a bug? Is there a workaround for this problem?
3
8108
by: KaOne | last post by:
Hi All, excuse me in advance for my not very perfect english. I need some help about a problem with a FormView bounded to an ObjectDataSource. In practise I have an ObjectDataSource that uses some BLL methods that implements the optimistic concurrency by a TimeStamp field into the DB. So, when I execute an insert, update or delete query if I receive 0 like return value from that queries I understand that a concurrency problem is occurs so...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10100
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.