Showing posts with label systemdatadatarowview. Show all posts
Showing posts with label systemdatadatarowview. Show all posts

Wednesday, March 7, 2012

DataBinding: System.Data.DataRowView does not contain a property with the name RMID.

I m trying to UPDATE database using FormView and SqlDataSource and here is my code:

<

asp:SqlDataSourceID="sqlDS1"runat="server"ConnectionString="<%$ ConnectionStrings:myDB %>"UpdateCommand="UPDATE [Consultants] SET [firstName]=@.FIRSTNAME,[lastName]=@.LASTNAME,[skillCategoryID]=@.SKILLCATID,[resourceManagerID]=@.RMID,[AMgroupID]=@.AMGROUPID,[SkillSet]=@.SKILLSET,[statusID]=@.STATUSID,[location]=@.LOCATION,[comments]=@.COMMENTS,[profile]=@.PROFILE,[isAvailable]=@.ISAVAILABLE,[dateModified]=getdate(),[focusID]=1 WHERE ([id]=@.ID)">

<

UpdateParameters><asp:FormParameterFormField="txtFName"Name="FIRSTNAME"/><asp:FormParameterFormField="txtLName"Name="LASTNAME"/><asp:FormParameterFormField="ddlSkillCat"Name="SKILLCATID"/><asp:FormParameterFormField="ddlRM"Name="RMID"/><asp:FormParameterFormField="ddlAMGroup"Name="AMGROUPID"/><asp:FormParameterFormField="txtSkillset"Name="SKILLSET"/><asp:FormParameterFormField="ddlStatus"Name="STATUSID"Type="Int16"/><asp:FormParameterFormField="txtLocation"Name="LOCATION"/><asp:FormParameterFormField="txtComments"Name="COMMENTS"/><asp:FormParameterFormField="txtProfile"Name="PROFILE"/><asp:FormParameterFormField="cbAvailable"Name="ISAVAILABLE"/><asp:QueryStringParameterType="Int32"Name="ID"QueryStringField="id"/></UpdateParameters></asp:SqlDataSource>

//*******************************************************************

<

asp:FormViewDefaultMode="Edit"ID="FormView1"runat="server"DataSourceID="sqlDS1"DataKeyNames="id"><EditItemTemplate>

<

tr><tdclass="blacktextbold">

Resource Manager:

</td><tdclass="blacktext"><asp:DropDownListID="ddlRM"CssClass="blacktext"runat="server"DataSource="<%#GetRM()%>"DataTextField="RMName"DataValueField="userID"SelectedValue="<%#Bind('RMID')%>"AppendDataBoundItems="true"><asp:ListItemValue="-1">--Select RM--</asp:ListItem></asp:DropDownList><asp:CustomValidatorID="cvRM"runat="server"ValidationGroup="gpInsert"ControlToValidate="ddlRM"ClientValidationFunction="validateDropdown"OnServerValidate="servervalidateDropdown"Display="Dynamic"ErrorMessage="Required Field"CssClass="redtextsmallbold"/></td></tr>

//********************************************************

here is my GetRM() function:

protected

DataSet GetRM()

{

string strConnection =ConfigurationManager.ConnectionStrings["myDB"].ToString();SqlConnection objConnection =newSqlConnection(strConnection);String sqlSkillCats ="SELECT Roles.roleID, Roles.roleName, UsersInRoles.userID, UsersInRoles.roleID AS Expr1, Users.firstName + ' ' + Users.lastName AS RMName, Users.id AS Expr2" +" FROM Users INNER JOIN" +" UsersInRoles ON Users.id = UsersInRoles.userID CROSS JOIN" +" Roles" +" WHERE (Roles.roleName = 'accountmanager') AND (UsersInRoles.roleID = Roles.roleID) ORDER BY Users.firstName";SqlDataAdapter objAdapter =newSqlDataAdapter(sqlSkillCats, objConnection);

objConnection.Open();

//ddlDataSet = new DataSet();try

{

objAdapter.Fill(dsConsultantRM,

"ConsultantRM");

}

catch (Exception ex)

{

Response.Write(ex.Message);

}

objConnection.Close();

return dsConsultantRM;

}

//******************************************************************

i get this error when i load the page:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'RMID'.

basically i m trying to UPDATE database using the value selected in the DropDownList, can anyone tell me whats wrong here...PLZ HELP!

I don't see a SelectCommand on your sqldatasource.|||

select command was in the function which returned the dataset. But that wasnt the issue, after changing all the CAPS parameter names to the exact name of the columns in my database i dint get any error!!!! i wonder why, for example i changed this:

<asp:parameter formfield="ddlRM" name="RMID"/>
TO
<asp:parameter formfield="ddlRM" name="resourceManagerID"/>

and then SelectedValue="<%#Bind('resourceManagerID')%>

Sunday, February 26, 2012

DataBinding: System.Data.DataRowView does not contain a property with the name Component_P

Hi,

Seems like a lot of people are having a similiar problem that I am having right now, but I am not able to find the solution to it. On the Page_load event, the gridview does display the data from database. When I click a button to insert the same data but different Waste_Profile_Num value, it gives me the databinding error. Component_Profile_ID is declared as an Identity and it is the primary key to the table. Anyway help?

Ok, the following are code that I have:

1 <asp:SqlDataSource ID="sqlDSMaterialComposition" runat="server" ConnectionString="<%$ ConnectionStrings:HAZConnectionString %>"2 SelectCommand="SELECT dbo.Component_Profile.Component_Profile_ID AS Component_Profile_ID, dbo.Component.Component, dbo.Component_Profile.Concentration, dbo.Component_Profile.Range, dbo.Component_Profile.Waste_Profile_Num, dbo.Component.Component_ID FROM dbo.Component INNER JOIN dbo.Component_Profile ON dbo.Component.Component_ID = dbo.Component_Profile.Component_ID WHERE (dbo.Component_Profile.Waste_Profile_Num = @.Waste_Profile_Num)">3 <SelectParameters>4 <asp:SessionParameter Name="Waste_Profile_Num" SessionField="Waste_Profile_Num" Type="Int32" />5 </SelectParameters>6 </asp:SqlDataSource>789 <asp:GridView ID="GridViewMaterialComposition"10 runat="server"11 DataKeyNames="Component_Profile_ID,Component_ID"12 AutoGenerateColumns="False" ShowFooter="true">13 <Columns>14 <asp:BoundField DataField="Component" HeaderText="Component" SortExpression="Component" FooterText="Total"/>15 <asp:TemplateField HeaderText="Concentration" FooterStyle-Font-Bold="true">16 <ItemTemplate>17 <%# SumConcentration(decimal.Parse(Eval("Concentration").ToString())).tostring("N2") %>18 </ItemTemplate>19 <FooterTemplate>20 <%# GetConcentration().tostring("N2") %>21 </FooterTemplate>22 </asp:TemplateField>23 <asp:BoundField DataField="Range" HeaderText="Range" SortExpression="Range" />24 <asp:BoundField DataField="Component_Profile_ID" HeaderText="Component_Profile_ID" ReadOnly="True" SortExpression="Component_Profile_ID" Visible="true" />25 <asp:BoundField DataField="Component_ID" HeaderText="Component_ID" ReadOnly="True" SortExpression="Component_ID" Visible="true"/>26 <asp:BoundField DataField="Waste_Profile_Num" HeaderText="Waste_Profile_Num" ReadOnly="true" SortExpression="Waste_Profile_Num" Visible="true" />27 <asp:CommandField ShowEditButton="true" />28 <asp:TemplateField Visible="false">29 <ItemTemplate>30 <asp:Label ID="lblComponentProfileID" runat="Server" Text='<% # Eval("Component_Profile_ID") %>'></asp:Label>31 <asp:Label ID="lblComponentID" runat="Server" Text='<% # Eval("Component_ID") %>'></asp:Label>32 </ItemTemplate>33 </asp:TemplateField>34 </Columns>35 </asp:GridView>
The following are the code-behind:
 
1 sqlSelect ="SELECT Range, Concentration, Component_ID FROM Component_Profile WHERE (Component_Profile.Waste_Profile_Num = " & previousWasteProfileNum &")"2 sqlDSMaterialComposition.SelectCommand = sqlSelect3Try4 Dim dvCompositionAs Data.DataView =CType(sqlDSMaterialComposition.Select(DataSourceSelectArguments.Empty), Data.DataView)5For Each drAs Data.DataRowIn dvComposition.Table.Rows6 insertSql ="INSERT INTO Component_Profile ([Range], [Concentration], [Component_ID], [Waste_Profile_Num]) "7 insertSql &="VALUES (" & dr("Range").ToString.Trim &", " & dr("Concentration").ToString.Trim &", " & dr("Component_ID").ToString.Trim &", " &CInt(Session("Waste_Profile_Num").ToString()) &")"8 sqlDSMaterialComposition.InsertCommand = insertSql9 sqlDSMaterialComposition.Insert()10Next11 Catch exAs Exception1213End Try

Hi guys,

that's ok. I have figured that out. I just need to databind the gridview after the for each statement

DataBinding: System.Data.DataRowView does not contain a property with the name

Here's a new one I came across that stumped me for a bit.

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'xxxx'.

It appears that one of my dropdown menus was referencing the old SqlDataSource1for its data source id.

I had already changed the name of the of the id to something else though.

To fix it, I just updated the reference to the new name.

Thought I'd share, just in case

Hi eterry,

Is this issue already resolved?

|||Yes it is. Sorry about that.