473,836 Members | 1,596 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checkboxlist inside a formview databind with objectdatasourc e(Please somebody help me)

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 25 '06 #1
0 2423

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

Similar topics

3
2924
by: I am Sam | last post by:
I keep getting the following error message when I try to iterate through a CheckBoxList control: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance...
2
8747
by: P. Yanzick | last post by:
Hello, I am creating an edit template for a FormView control, changing one of the textboxes to a dropdown box. The dropdown will be populated from a simple table with the primary key, and a description (i.e. a colors table, so there is a colors ID and a color description). The data source the FormView is pulling data from stores (in this example) the primary key for the colors table. My ultimate goal is when the FormView goes into...
0
2183
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
3590
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
0
958
by: settyv | last post by:
Hi, I want to add new column to the Datatable which is returned from Business layer.Will the below code work? Case BCase=new Case(); BCase.SearchEvents(sp,out ds); DataColumn c1 = new DataColumn("View PDF", Type.GetType("System.string")); ds.Tables.Columns.Add(c1);
0
3528
by: avital | last post by:
Hi, Hope someone can please help. I have a Gridview with a checkboxlist. On edititemTemplate I want the checkboxlist items to be selected as returned from the database. In the database I have a table called PrescriptionDetails with a field called Weekdays that can store data in the following format: Monday,Tuesday,Thursday,
2
2108
by: J055 | last post by:
Hi I have 2 user controls and 1 parent page. One user control contains a Gridview and the other a FormView. When the GridView row Select command is fired it bubbles an event to the parent page with the primary key ID of the row. The parent page sets a property with the ID in the second User control (FormView) . The FormView then Binds to an ObjectDataSource to select the record. I don't understand why the events occur as follows: ...
4
1545
by: Victor | last post by:
Hi all Do I have to call my databind event for my control in the page_load event? I try to call my databind event for my contorl in the loadcomplete event. but seems it doesn't work at all Pls help. Cheers
6
3514
by: dbuchanan | last post by:
There are three parts to this 1.) How do I cascade menus? 2.) And, how do I cascade menus with a multi-select CheckBoxList?
0
9826
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9674
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10860
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
10560
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
10604
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
10261
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
9389
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...
0
5659
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4026
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.