I have put together a web form to track outage times of a website that my company is using. However, I'm receiving the error in the subject line when I'm trying to use the update feature of a gridview. Listed below is the code that I'm using. If anybody
has any suggestions or questions, I seemed to get to a point where I can't go any further. I'm not having any obvious issues when inserting data, just updating pre-existing records.
I see it odd, that the SelectedItem when set to Bind will work when inserting but not updating. There's alot of lose ends with this and by looking at examples online, and doing some research, this looks like it should work. The RadioListButton control,
when going into Edit mode, does not show the selection that was set in the DB, which I believe is part of the problem. When selecting values, wether they be the same or different show the error that is in the subject.
Would anybody know of an easier way of using Radiobuttons, and adding/updating values in a DB than what I have within the example of code?
To Clear this up, when inserting selectedvalues, I am using the formview control (insertitem template). When trying to edit selected values, I am doing so with a gridview control in editmode. I have set up the radiolistbutton control with 2 way binding,
directly to the DB column. This is the same way that I have it in the formview. Would anybody know the best way to put a record, in editmode, and having values retrieved from a DB directly into selected radio buttons?
When the gridview is in edit mode, and selecting update is when I receive this. This is of course after selecting the radio buttons of choice, not matter what is selected.
if i exit after "exit 2", i see "exit 2" in the textbox. If I continue to "exit 2A", I get the "No mapping exists..." error. Assigning a string to the text property of a textbox. How can it work on one line and not two lines down?
"No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type."
There is of course code above the "exit 2" assignment, and code following the "exit 2A" assignment. There is no code between the two lines. It's all shown in the snippet.
tekvaio
Member
626 Points
127 Posts
No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed provider...
Jul 11, 2006 09:34 PM|LINK
I have put together a web form to track outage times of a website that my company is using. However, I'm receiving the error in the subject line when I'm trying to use the update feature of a gridview. Listed below is the code that I'm using. If anybody has any suggestions or questions, I seemed to get to a point where I can't go any further. I'm not having any obvious issues when inserting data, just updating pre-existing records.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Outage_Tracker.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head id="Head1" runat="server">
<title>ESS Outage Tracker</title>
</head>
<body>
<form id="Form1" runat="server">
<asp:Label id="EditMSG" Height="25" ForeColor="Red" Runat="Server"
EnableViewState="False"/>
<asp:Label id="ConfirmDelete" Visible="False" Runat="Server"
EnableViewState="False" Height="25"><asp:Label ID="Label1" Text="Delete this record? " Runat="Server"
ForeColor="Red" EnableViewState="False"/>
<asp:Button ID="Button1" Text="Yes" OnClick="Delete_Record" Runat="Server"
Font-Size="7pt" Width="30px"/>
<asp:Button ID="Button2" Text="No" OnClick="Cancel_Delete" Runat="Server"
Font-Size="7pt" Width="30px"/>
</asp:Label>
<asp:FormView id="AddForm" runat="server" DataSourceID="AddSource" InsertRowStyle-BackColor="#00EE00" OnItemInserting="Validate_Insert_Data" OnItemInserted="Insert_Record">
<HeaderTemplate>
<table id="Head" border="1">
<tr>
<th><asp:Label ID="Label3" Text="Date" Width="210px" Runat="Server"/></th>
<th><asp:Label ID="Label10" Text="Date" Width="210px" Runat="Server"/></th>
<th><asp:Label ID="Label6" Text="Reports" Width="40px" Runat="Server"/></th>
<th><asp:Label ID="Label7" Text="Realm" Width="90px" Runat="Server"/></th>
<th><asp:Label ID="Label9" Text="Scheduled" Width="90px" Runat="Server"/></th>
<th><asp:Label ID="Label8" Text="Notes" Width="200px" Runat="Server"/></th>
<th><asp:Label ID="Label2" Text="Edit" Width="72px" Runat="Server"/></th>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table id="Edit" border="1">
<tr>
<td><asp:Button ID="Button3" Text="New" CommandName="New" Font-Size="7pt" Width="35px" Runat="Server"/></td>
</tr>
</table>
</ItemTemplate>
<InsertItemTemplate>
<table id="Insert" border="1">
<tr>
<td>
<asp:Calendar ID="Calendar1" Width="150px" SelectedDate='<%# Bind("date_down") %>' ToolTip="Select Date of Outage" FirstDayOfWeek="Sunday" runat="server"></asp:Calendar><br><center>Time: <asp:TextBox id="timeDown" Runat="Server"
Text='<%# Bind("time_down") %>'
Font-Size="8pt" Width="80px"/></center>
</td>
<td><asp:Calendar ID="Calendar2" Width="150px" SelectedDate='<%# Bind("date_up") %>' ToolTip="Select Date ESS returned Online" FirstDayOfWeek="Sunday" runat="server"></asp:Calendar><br><center>Time: <asp:TextBox id="timeUp" Runat="Server"
Text='<%# Bind("time_up") %>'
Font-Size="8pt" Width="80px"/></center>
</td>
<td><asp:RadioButtonList RepeatDirection="vertical" Width="40px" ID="RadioButtonList1" runat="server" SelectedValue='<%# Bind("reports") %>'>
<asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
<asp:ListItem Text="No" Value="No"></asp:ListItem>
</asp:RadioButtonList></td>
<td>
<asp:RadioButtonList RepeatDirection="Vertical" Width="40px" ID="radRealm" runat="server" SelectedValue='<%# Bind("realm") %>'>
<asp:ListItem Text="Production" Value="Production"></asp:ListItem>
<asp:ListItem Text="Training" Value="Training"></asp:ListItem>
<asp:ListItem Text="ST" Value="ST"></asp:ListItem>
<asp:ListItem Text="Pilot" Value="Pilot"></asp:ListItem>
</asp:RadioButtonList>
</td>
<td><asp:RadioButtonList RepeatDirection="vertical" Width="90px" ID="radSched" runat="server" SelectedValue='<%# Bind("scheduled") %>'>
<asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
<asp:ListItem Text="No" Value="No"></asp:ListItem>
</asp:RadioButtonList>
</td>
<td><asp:TextBox id="notes" Runat="Server"
Text='<%# Bind("notes") %>'
TextMode="MultiLine" Rows="12" Font-Names="Arial"
Font-Size="8pt" Width="200"/>
</td>
<td nowrap>
<asp:Button ID="Button4" Text="Insert" CommandName="Insert" Runat="Server"
Font-Size="7pt" Width="35px"/>
<asp:Button ID="Button5" Text="Cancel" CommandName="Cancel" Runat="Server"
Font-Size="7pt" Width="35px"/></td>
</tr>
</table>
</InsertItemTemplate>
<InsertRowStyle BackColor="#00EE00" />
</asp:FormView>
<asp:GridView id="EditGrid" DataSourceID="EditSource" Runat="Server"
AutoGenerateColumns="False"
DataKeyNames="date_down"
ShowHeader="False"
AllowPaging="True"
PageSize="5"
EditRowStyle-BackColor="#FFFF00"
PagerStyle-BackColor="#E0E0E0"
OnRowUpdating="Validate_Update_Data"
OnRowUpdated="Update_Record"
OnRowDeleting="Confirm_Delete">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label12" Text='<%# Bind("date_down","{0:d}") %>' Runat="Server"
Width="150px"/><asp:Label ID="Label13" Text='<%# Bind("time_down","{0:T}") %>' Font-Size="8pt" Runat="Server"
Width="70px"/>
</ItemTemplate>
<EditItemTemplate>
<asp:Calendar ID="Calendar1" SelectedDate='<%# Bind("date_down","{0:d}") %>' Width="150px" runat="server"></asp:Calendar><br><center>Time: <asp:TextBox id="txtTimeDown" Runat="Server"
Text='<%# Bind("time_down","{0:T}") %>'
Width="70px" Font-Size="8pt"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label11" Text='<%# Bind("date_up","{0:d}") %>' Runat="Server"
Width="150px"/><asp:Label ID="Label14" Text='<%# Bind("time_up","{0:T}") %>' Font-Size="8pt" Runat="Server"
Width="70px"/></center>
</ItemTemplate>
<EditItemTemplate>
<asp:Calendar ID="Calendar2" SelectedDate='<%# Bind("date_up","{0:d}") %>' Width="150px" runat="server"></asp:Calendar><br><center>Time: <asp:TextBox id="txtTimeUp" Runat="Server"
Text='<%# Bind("time_up","{0:T}") %>'
Width="70px" Font-Size="8pt"/></center>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label15" Text='<%# Bind("reports") %>' Runat="Server"
Width="40px"/>
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList Width="40px" RepeatDirection="vertical" ID="radReports" runat="server" SelectedItem='<%# Bind("reports") %>'>
<asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
<asp:ListItem Text="No" Value="No"></asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label16" Width="90px" Text='<%# Bind("realm") %>' Runat="Server"/>
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList Width="90px" RepeatDirection="Vertical" ID="radRealm" runat="server" SelectedItem='<%# Bind("realm") %>'>
<asp:ListItem Text="Production" Value="Production"></asp:ListItem>
<asp:ListItem Text="Training" Value="Training"></asp:ListItem>
<asp:ListItem Text="ST" Value="ST"></asp:ListItem>
<asp:ListItem Text="Pilot" Value="Pilot"></asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label17" Text='<%# Bind("scheduled") %>'
Width="90px" Runat="Server"/>
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList Width="90px" RepeatDirection="vertical" ID="radSched" runat="server" SelectedItem='<%# Bind("scheduled") %>'>
<asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
<asp:ListItem Text="No" Value="No"></asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label18" Text='<%# Bind("notes") %>'
Width="200px" Runat="Server"/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="notes" Runat="Server"
Text='<%# Bind("notes") %>'
TextMode="MultiLine" Rows="12" Font-Names="arial"
Font-Size="8pt" Width="200px"/>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button6" Text="Edit" CommandName="Edit" Runat="Server"
Font-Size="7pt" Width="36px"/>
<asp:Button ID="Button7" Text="Delete" CommandName="Delete" Runat="Server"
Font-Size="7pt" Width="36px"/>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="Button8" Text="Update" CommandName="Update" Runat="Server"
Font-Size="7pt" Width="36px"/>
<asp:Button ID="Button9" Text="Cancel" CommandName="Cancel" Runat="Server"
Font-Size="7pt" Width="36px"/>
</EditItemTemplate>
<ItemStyle Wrap="False" />
</asp:TemplateField>
</Columns>
<RowStyle Font-Size="10pt" VerticalAlign="Top" />
<EditRowStyle BackColor="Yellow" />
<PagerStyle BackColor="#E0E0E0" />
</asp:GridView>
<asp:SqlDataSource ID="AddSource" runat="server" ConnectionString="<%$ ConnectionStrings:outageConnectionString2 %>"
</div>SelectCommand="SELECT TOP 1 * FROM [tblOutage]" InsertCommand="INSERT INTO tblOutage(date_down, time_down, date_up, time_up, notes, scheduled, reports, realm) VALUES (@date_down, @time_down, @date_up, @time_up, @notes, @scheduled, @reports, @realm)">
<InsertParameters>
<asp:Parameter Name="date_down" />
<asp:Parameter Name="time_down" />
<asp:Parameter Name="date_up" />
<asp:Parameter Name="time_up" />
<asp:Parameter Name="notes" />
<asp:Parameter Name="scheduled" />
<asp:Parameter Name="reports" />
<asp:Parameter Name="realm" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="EditSource" runat="server" ConnectionString="<%$ ConnectionStrings:outageConnectionString2 %>" SelectCommand="SELECT * FROM [tblOutage] ORDER BY [date_down]" UpdateCommand="UPDATE tblOutage SET date_down = @date_down, time_down = @time_down, date_up = @date_up, time_up = @time_up, notes = @notes, scheduled = @scheduled, reports = @reports, realm = @realm WHERE (ID = @ID)">
<UpdateParameters>
<asp:Parameter Name="date_down" />
<asp:Parameter Name="time_down" />
<asp:Parameter Name="date_up" />
<asp:Parameter Name="time_up" />
<asp:Parameter Name="notes" />
<asp:Parameter Name="scheduled" />
<asp:Parameter Name="reports" />
<asp:Parameter Name="realm" />
</UpdateParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
tekvaio
Member
626 Points
127 Posts
Re: No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed prov...
Jul 12, 2006 02:30 PM|LINK
Has anybody seen this issue? I have to come across anywhere that has this error documented nor have a way to correct this.
Thanks,
TV
tekvaio
Member
626 Points
127 Posts
Re: No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed prov...
Jul 13, 2006 07:40 PM|LINK
I see it odd, that the SelectedItem when set to Bind will work when inserting but not updating. There's alot of lose ends with this and by looking at examples online, and doing some research, this looks like it should work. The RadioListButton control, when going into Edit mode, does not show the selection that was set in the DB, which I believe is part of the problem. When selecting values, wether they be the same or different show the error that is in the subject.
Would anybody know of an easier way of using Radiobuttons, and adding/updating values in a DB than what I have within the example of code?
Thanks,
TV
tekvaio
Member
626 Points
127 Posts
Re: No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed prov...
Jul 19, 2006 07:40 PM|LINK
To Clear this up, when inserting selectedvalues, I am using the formview control (insertitem template). When trying to edit selected values, I am doing so with a gridview control in editmode. I have set up the radiolistbutton control with 2 way binding, directly to the DB column. This is the same way that I have it in the formview. Would anybody know the best way to put a record, in editmode, and having values retrieved from a DB directly into selected radio buttons?
TV
Sjonnie2nd
Participant
1125 Points
221 Posts
Re: No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed prov...
Jul 20, 2006 09:56 AM|LINK
TV,
Finally a reply :D
Obviously there's something wrong with the fieldbinding.
When does the error occur?
When the gridview renders in Editmode? A known issue here is that the default Radiobuttonlist doesn't handle DBNull values.
Or.. when you try to post the changes?
Sjonnie
tekvaio
Member
626 Points
127 Posts
Re: No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed prov...
Jul 20, 2006 02:13 PM|LINK
When the gridview is in edit mode, and selecting update is when I receive this. This is of course after selecting the radio buttons of choice, not matter what is selected.
Thanks,
TV
Sjonnie2nd
Participant
1125 Points
221 Posts
Re: No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed prov...
Jul 20, 2006 07:30 PM|LINK
Tekvaio,
I reread your code and...
You try to bind a field to the SelectedItem property of the RadioButtonList. SelectedItem is of type object.
Change SelectedItem to SelectedValue and it must work.
Sjonnie
barryman9000
Participant
1698 Points
605 Posts
Re: No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed prov...
Oct 11, 2006 10:25 PM|LINK
I'm not sure if you resolved this, but I was getting the same error using the TextBox control:
No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type.
The reason was, I was databinding to the Textbox, and not the Text property of the TextBox:
Command.Parameter.Add("dbfield", tbInsert)
Instead of:
Command.Parameter.Add("dbfield", tbInsert.Text)
I hope that helps!
- George Carlin
amalavasi
Member
6 Points
7 Posts
Re: No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed prov...
Oct 26, 2007 09:24 PM|LINK
If you use .selectedItem.toString(), it works as well
RickInHousto...
Member
32 Points
21 Posts
Same problem, but textbox "No mapping exists from object type System.Web.UI.WebControls.TextBox
Aug 31, 2008 02:31 PM|LINK
if i exit after "exit 2", i see "exit 2" in the textbox. If I continue to "exit 2A", I get the "No mapping exists..." error. Assigning a string to the text property of a textbox. How can it work on one line and not two lines down?
"No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type."
There is of course code above the "exit 2" assignment, and code following the "exit 2A" assignment. There is no code between the two lines. It's all shown in the snippet.
I am obviously missing something.
this.txtMessageFromStore.Text = "exit 2";
//return;
try
{
this.txtMessageFromStore.Text = "exit 2A";
managed provider mapping system.web.ui.webcontrols
www.AccessRocks.com