473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

Jai
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>
<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" AssociatedControlID="lblEditUserName" Text="User Name:"

Width="100px"></asp:Label></td>
<td align="left" style="width:
100px; height: 16px;">
<asp:Label
ID="lblEditUserName" 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="lblFirstName" runat="server" AssociatedControlID="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="textbox"></asp:TextBox></td>
<td align="left" style="width:
100px">
</td>
</tr>
<tr>
<td align="left" style="width:
100px">
<asp:Label ID="lblLastName"
runat="server" AssociatedControlID="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="textbox"></asp:TextBox></td>
<td align="left" style="width:
100px">
</td>
</tr>
<tr>
<td align="left" style="width:
100px">
<asp:Label ID="lblEmail"
runat="server" AssociatedControlID="Email" Text="Email:"

Width="57px"></asp:Label></td>
<td align="left" style="width:
98px">
<asp:TextBox ID="Email"
runat="server" Text='<%# Bind("Email") %>'
CssClass="textbox"></asp:TextBox>
<asp:RequiredFieldValidator
ID="EmailRequired" runat="server" ControlToValidate="Email"
Display="Dynamic" ErrorMessage="Email
is a required field."
ValidationGroup="modifyProfile">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="EmailFormat" runat="server" ControlToValidate="Email"
Display="Dynamic" ErrorMessage="The
email format is invalid." ValidationExpression="\S+@\S+\.\S+"

ValidationGroup="modifyProfile">*</asp:RegularExpressionValidator></td>
<td align="left" style="width:
100px">
</td>
</tr>
<tr>
<td align="left" style="width: 100px">
<asp:Label ID="lblEditOccupation"
runat="server" AssociatedControlID="cbEditOccupation"
Text="Occupation"></asp:Label></td>
<td align="left" style="width: 98px">
<asp:CheckBoxList ID="cbEditOccupation"
runat="server" AppendDataBoundItems="true" DataTextField='<%#
Bind("Occupation") %>'
DataValueField='<%#
Bind("Occupation") %>' RepeatColumns="2" RepeatDirection="Horizontal">

<asp:ListItem>Shopkeeper</asp:ListItem>

<asp:ListItem>Publisher</asp:ListItem>

<asp:ListItem>Teacher</asp:ListItem>

<asp:ListItem>Scientist</asp:ListItem>
</asp:CheckBoxList></td>
<td align="left" style="width: 100px">
</td>
</tr>

<tr>
<td align="left" style="width: 100px">
</td>
<td align="left" style="width: 100px">
<asp:ValidationSummary
ID="ValidationSummary1" runat="server" DisplayMode="List"
ValidationGroup="modifyProfile" />
<asp:ImageButton ID="btnUpdate"
runat="server" CommandName="Update"
SkinID="save" ToolTip="Save"
ValidationGroup="modifyProfile" />
<asp:ImageButton ID="btnCancel"
runat="server" CausesValidation="False" CommandName="Cancel"
SkinID="cancel" ToolTip="Cancel" />

</td>
</tr>
</table>
</EditItemTemplate>
<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" AssociatedControlID="UserNameLabel"
Text="User Name:"

Width="100px"></asp:Label></td>
<td align="left"
style="width: 100px; height: 16px;">
<asp:Label
ID="UserNameLabel" 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="lblFirstName" runat="server" AssociatedControlID="FirstNameLabel"
Text="First Name:"
Width="57px"></asp:Label></td>
<td align="left"
style="width: 100px">
<asp:Label
ID="FirstNameLabel" 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" AssociatedControlID="LastNameLabel"
Text="Last Name:"

Width="57px"></asp:Label></td>
<td align="left"
style="width: 100px">
<asp:Label
ID="LastNameLabel" 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" AssociatedControlID="EmailLabel"
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="lblOccupation"
runat="server" AssociatedControlID="cbOccupation"
Text="Occupation"></asp:Label></td>
<td align="left" style="width: 100px">
<asp:CheckBoxList ID="cbOccupation"
runat="server" DataSourceID="ObjectDataSource1"
AppendDataBoundItems="true" DataTextField='<%# Bind("Occupation") %>'
DataValueField='<%# Bind("Occupation") %>'
RepeatColumns="2"
RepeatDirection="Horizontal" Enabled="false">

<asp:ListItem>Shopkeeper</asp:ListItem>

<asp:ListItem>Publisher</asp:ListItem>

<asp:ListItem>Teacher</asp:ListItem>

<asp:ListItem>Scientist</asp:ListItem>
</asp:CheckBoxList></td>
<td align="left" style="width: 100px">
</td>
</tr>

<tr>
<td align="left" style="width: 100px">
</td>
<td align="left" style="width: 100px">
<asp:ImageButton ID="btnEdit"
runat="server" CausesValidation="False" CommandName="Edit"
SkinID="edit" ToolTip="Edit" />

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

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetUser"
TypeName="Membership.MembershipManager"
UpdateMethod="EditUser">
<UpdateParameters>
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Occupation" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:ProfileParameter Name="UserName"
PropertyName="UserName" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>

SourceCode:---------

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

Dim p As SiteUser =
ProfileManager.GetUserProfileInfo(UserName)
Dim user As MembershipUser =
System.Web.Security.Membership.GetUser(UserName)

If Not (p Is Nothing) Then

If Not (p Is Nothing) Then
Return New SiteUser(p.UserName, p.FirstName,
p.LastName, p.Occupation, p.Password, p.Email, p.Question, p.Answer)
Else
Return New SiteUser(p.UserName, "", "", "", "", "",
"", "")
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.Security.Membership.GetUser(UserName)
If Not IsNothing(user) Then
user.Email = Email
user.IsApproved = IsApproved
Try
System.Web.Security.Membership.UpdateUser(user)
ProfileManager.UpdateUserProfileInfo(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="Occupation" 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(checkboxlist is inside a formview)

Please...Please help me....

Thanks in advance.....

Sep 25 '06 #1
0 2395

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

Similar topics

3
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...
2
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...
0
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...
0
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...
0
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...
0
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...
2
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...
4
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...
6
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
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,...
0
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...

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.