Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hi Everyone,
I am getting this exception(DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'itemno')in my project. Please help me to fix this bug.
 
Regards
Nanda
 
DESIGN:
<asp:GridView ID="grdview1" runat="server" AutoGenerateColumns="False" Width="100%" DataKeyNames="itemno"
                                                                                CellPadding="4" ForeColor="#333333" GridLines="None"  OnRowDataBound="grdview1_RowDataBound">
                                                                                <RowStyle BackColor="#F2FAFD" HorizontalAlign="Left" />
                                                                                <Columns>
                                                                                    <asp:TemplateField HeaderText="Select Solenoid valve with Required Voltage" HeaderStyle-HorizontalAlign="Left"
                                                                                        ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:DropDownList ID="ddlWoItem" runat="server" Width="180px" AutoPostBack="true"
                                                                                                OnSelectedIndexChanged="ddlWoItem_SelectedIndexChanged">
                                                                                            </asp:DropDownList>
                                                                                        </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Available Quanity" HeaderStyle-HorizontalAlign="Left"
                                                                                        ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:TextBox ID="txtWoQty" runat="server" Text='<%#Bind("reqqty")%>'></asp:TextBox>
                                                                                        </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Conversion Qty" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:TextBox ID="txtConversionQty" runat="server" Width="60px"></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Rate" ItemStyle-HorizontalAlign="Left">
                                                                                    <ItemTemplate><asp:TextBox ID="txtStkRate" runat="server" Text='<%#Bind("woitemrate")%>' Width="60px">
                                                                                    </asp:TextBox>
                                                                                    </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Select Valve To Be Convert" HeaderStyle-HorizontalAlign="Left"
                                                                                        ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:DropDownList ID="ddlRequiredValve" runat="server" Width="180px" AutoPostBack="true"
                                                                                                OnSelectedIndexChanged="ddlRequiredValve_SelectedIndexChanged">
                                                                                            </asp:DropDownList>
                                                                                        </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Avail Valve Qty" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:TextBox ID="txtReqQty" runat="server" Width="60px" Text='<%#Bind("replacevalveqty") %>'></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Valve Serial no" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                        <%--<asp:DropDownList ID="ddlReqValveSlNo" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlReqValveSlNo_SelectedIndexChanged"></asp:DropDownList>--%>
                                                                                            <asp:TextBox ID="txtSNo" runat="server" Width="60px" Text='<%#Bind("reqvalveserialno") %>'></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Replace Valve Qty" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:TextBox ID="txtValveQty" runat="server"></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Rate" ItemStyle-HorizontalAlign="Left">
                                                                                    <ItemTemplate><asp:TextBox ID="txtRate" runat="server" Text='<%#Bind("reqvalverate")%>' Width="60px"></asp:TextBox>
                                                                                    </ItemTemplate>
                                                                                    </asp:TemplateField>
 
<%--
<asp:TemplateField HeaderText="Item No" ItemStyle-HorizontalAlign="Left" Visible="false">
<ItemTemplate><asp:Label ID="itemno" runat="server" Text='<%#Bind("itemno")%>' Visible="false"></asp:Label></ItemTemplate>
</asp:TemplateField> --%>
                                                                                    <asp:TemplateField HeaderText="Select Required Coil" HeaderStyle-HorizontalAlign="Left"
                                                                                        ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:DropDownList ID="ddlDetachCoil" runat="server" Width="180px" AutoPostBack="true"
                                                                                                OnSelectedIndexChanged="ddlDetachCoil_SelectedIndexChanged">
                                                                                            </asp:DropDownList>
                                                                                        </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Coil Avail Qty" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:TextBox ID="txtitemno" runat="server" Text='<%#Bind("reqdetachcoilqty") %>'></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Replace Coil Qty" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:TextBox ID="txtReplaceCoilQty" runat="server"></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Addition of the Coil to Stock" HeaderStyle-HorizontalAlign="Left"
                                                                                        ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:DropDownList ID="ddlCoilDetach" runat="server" Width="180px" AutoPostBack="true"
                                                                                                OnSelectedIndexChanged="ddlCoilDetach_SelectedIndexChanged">
                                                                                            </asp:DropDownList>
                                                                                        </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Available Qty" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:TextBox ID="detachcoilqty" runat="server" Text='<%#Bind("reqvalveqty") %>'></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                      <asp:TemplateField HeaderText="Rate" ItemStyle-HorizontalAlign="Left">
                                                                                    <ItemTemplate><asp:TextBox ID="txtCoilRate" runat="server" Text='<%#Bind("refdeachcoilrate")%>' Width="60px"></asp:TextBox>
                                                                                    </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <%--<asp:TemplateField HeaderText="Selected Valve" HeaderStyle-HorizontalAlign="Left"
                                                                                            ItemStyle-HorizontalAlign="Left">
                                                                                            <ItemTemplate>
                                                                                                <asp:DropDownList ID="ddlUPdateValve" runat="server" Width="180px" AutoPostBack="true"
                                                                                                    OnSelectedIndexChanged="ddlUPdateValve_SelectedIndexChanged">
                                                                                                </asp:DropDownList>
                                                                                            </ItemTemplate>
                                                                                        </asp:TemplateField>
                                                                                        <asp:TemplateField HeaderText="Avail Qty" ItemStyle-HorizontalAlign="Left">
                                                                                            <ItemTemplate>
                                                                                                <asp:TextBox ID="txtSelectedQty" runat="server"  ></asp:TextBox></ItemTemplate>
                                                                                        </asp:TemplateField>
                                                                                        <asp:TemplateField HeaderText="Serial No" ItemStyle-HorizontalAlign="Left">
                                                                                            <ItemTemplate>
                                                                                                <asp:TextBox ID="txtSerialNo" runat="server"></asp:TextBox></ItemTemplate>
                                                                                        </asp:TemplateField>
                                                                                        <asp:TemplateField HeaderText="Replace Quantity" ItemStyle-HorizontalAlign="Left">
                                                                                            <ItemTemplate>
                                                                                                <asp:TextBox ID="txtReplaceValveCoilQty" runat="server"></asp:TextBox></ItemTemplate>
                                                                                        </asp:TemplateField> --%>
                                                                                    <%--<asp:TemplateField HeaderText="Selected Valve" HeaderStyle-HorizontalAlign="Left"
                                                                                            ItemStyle-HorizontalAlign="Left">
                                                                                            <ItemTemplate>
                                                                                                <asp:DropDownList ID="ddlValve" runat="server" Width="180px" AutoPostBack="true"
                                                                                                    OnSelectedIndexChanged="ddlValve_SelectedIndexChanged">
                                                                                                </asp:DropDownList>
                                                                                            </ItemTemplate>
                                                                                        </asp:TemplateField>
                                                                                        <asp:TemplateField HeaderText="Avail Qty" ItemStyle-HorizontalAlign="Left">
                                                                                            <ItemTemplate>
                                                                                                <asp:TextBox ID="txtValve" runat="server"  ></asp:TextBox></ItemTemplate>
                                                                                        </asp:TemplateField>
 
                                                                                       <asp:TemplateField HeaderText="Serial No" ItemStyle-HorizontalAlign="Left">
                                                                                            <ItemTemplate>
                                                                                                <asp:TextBox ID="txtSLNO" runat="server"></asp:TextBox></ItemTemplate>
                                                                                        </asp:TemplateField>
                                                                                        --%>
                                                                                    <asp:TemplateField HeaderText="Select Required Coil From the Valve" HeaderStyle-HorizontalAlign="Left"
                                                                                        ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:DropDownList ID="ddlSValve" runat="server" Width="180px" AutoPostBack="true"
                                                                                                OnSelectedIndexChanged="ddlSValve_SelectedIndexChanged">
                                                                                            </asp:DropDownList>
                                                                                        </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Avail Qty" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:TextBox ID="txtSValve" runat="server" Text='<%#Bind("replaceselectvalve") %>'></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Serial No" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                        <%--<asp:DropDownList ID="ddlSelectValveSlNo" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlSelectValveSlNo_SelectedIndexChanged"></asp:DropDownList>--%>
                                                                                            <asp:TextBox ID="txtSSLNO" runat="server" Text='<%#Bind("selectvalveslno") %>'></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Replace Qty" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:TextBox ID="txtSReplace" runat="server"></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Rate" ItemStyle-HorizontalAlign="Left">
                                                                                    <ItemTemplate><asp:TextBox ID="txtSelectRate" runat="server" Text='<%#Bind("selectvalverate")%>' Width="60px"></asp:TextBox>
                                                                                    </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Valve Without Coil Stock" HeaderStyle-HorizontalAlign="Left"
                                                                                        ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:DropDownList ID="ddlSelectValve" runat="server" Width="180px" AutoPostBack="true"
                                                                                                OnSelectedIndexChanged="ddlSelectValve_SelectedIndexChanged">
                                                                                            </asp:DropDownList>
                                                                                        </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Avail Qty" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                            <asp:TextBox ID="refavailqty" runat="server" Text='<%#Bind("selectvalveqty") %>'></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Serial No" ItemStyle-HorizontalAlign="Left">
                                                                                        <ItemTemplate>
                                                                                        <%--<asp:DropDownList ID="ddlRefValveSlNo" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlRefValveSlNo_SelectedIndexChanged"></asp:DropDownList>--%>
                                                                                            <asp:TextBox ID="slno" runat="server" Text='<%#Bind("refserialno") %>'></asp:TextBox></ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                    <asp:TemplateField HeaderText="Rate" ItemStyle-HorizontalAlign="Left">
                                                                                    <ItemTemplate><asp:TextBox ID="txtRefRate" runat="server" Text='<%#Bind("refvalverate")%>' Width="60px"></asp:TextBox>
                                                                                    </ItemTemplate>
                                                                                    </asp:TemplateField>
                                                                                </Columns>
                                                                                <FooterStyle BackColor="#122D48" Font-Bold="True" ForeColor="White" />
                                                                                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                                                                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                                                                <HeaderStyle BackColor="#122D48" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
                                                                                <EditRowStyle BackColor="#2461BF" />
                                                                                <AlternatingRowStyle BackColor="#E3F4FB" />
                                                                            </asp:GridView>
public void BindGridView(int num, int ch)
   {
grdview1.Visible = true;
 
        SqlCommand cmd = new SqlCommand("spGetTblCoilConversionDetails");
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@ocno", SqlDbType.Int).Value = num;
        cmd.Parameters.Add("@companyid", SqlDbType.Int).Value = Convert.ToInt16(Session["companyid"]);
        cmd.Parameters.Add("@ch", SqlDbType.Int).Value = ch;
        // cmd.Parameters.Add("@qty", SqlDbType.Int).Value = 0;
        DataSet ds = ems.Make_Ds(cmd, con);
        grdview1.DataSource = ds;
        grdview1.DataBind();
 
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
 
            DropDownList ddlWoItem = ((DropDownList)grdview1.Rows[i].FindControl("ddlWoItem"));
            ddlWoItem.SelectedValue = ds.Tables[0].Rows[i][0].ToString();
 
        }
        if (ch == 2)
        {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (i == 0)
                {
                    grdview1.Columns[14].Visible = (ds.Tables[0].Rows[0]["selectvalve"] != DBNull.Value);
                    grdview1.Columns[9].Visible = (ds.Tables[0].Rows[0]["reqdetachcoil"] != DBNull.Value);
                }
                DropDownList ddlWoItem = ((DropDownList)grdview1.Rows[i].FindControl("ddlWoItem"));
                ddlWoItem.SelectedValue = ds.Tables[0].Rows[i]["woitemcode"].ToString();
                DropDownList ddlRequiredValve = ((DropDownList)grdview1.Rows[i].FindControl("ddlRequiredValve"));
                ddlRequiredValve.SelectedValue = ds.Tables[0].Rows[i]["reqvalve"].ToString();
                DropDownList ddlDetachCoil = ((DropDownList)grdview1.Rows[i].FindControl("ddlDetachCoil"));
                ddlDetachCoil.SelectedValue = ds.Tables[0].Rows[i]["reqdetachcoil"].ToString();
                DropDownList ddlSValve = ((DropDownList)grdview1.Rows[i].FindControl("ddlSValve"));
                ddlSValve.SelectedValue = ds.Tables[0].Rows[i]["selectvalve"].ToString();
                DropDownList ddlCoilDetach = ((DropDownList)grdview1.Rows[i].FindControl("ddlCoilDetach"));
                ddlCoilDetach.SelectedValue = ds.Tables[0].Rows[i]["refdetachcoil"].ToString();
                DropDownList ddlSelectValve = ((DropDownList)grdview1.Rows[i].FindControl("ddlSelectValve"));
                ddlSelectValve.SelectedValue = ds.Tables[0].Rows[i]["refvalvecoil"].ToString();
            }
        }}
Store procedure:
ALTER proc [dbo].[spGetTblCoilConversionDetails]
@ocno int,
@companyid int,
@ch int
as
begin
declare @stockqty float
declare @qty1 int
declare @serialno varchar(2048)
declare @rate numeric(18,0)
 

 
if @ch=1
begin
select top 1(itemcode) as woitemcode,companyid,ocno as wono,dbo.fnGetAvailStockQty(itemcode,@companyid)as reqqty,(select @rate) as woitemrate,(select @stockqty)as replacevalveqty,(select @serialno)as reqvalveserialno,(select @rate)as reqvalverate,(select @stockqty)as reqdetachcoilqty,
(select @stockqty)as reqvalveqty,(select @stockqty)as replaceselectvalve,(select @rate) as refdeachcoilrate,(select @serialno)as selectvalveslno,(select @stockqty)as selectvalveqty,(select @rate)as refvalverate,(select @serialno)as refserialno,(select @rate)as selectvalverate from tblocdetails where ocno=@ocno and companyid=@companyid group by itemcode,companyid,ocno,availableqty having availableqty<sum(qty)>
end
 

if @ch=2
begin
select companyid,conversionno,ocno,woitemcode,reqvalve,reqvalveserialno,dbo.fnGetAvailStockQty(reqvalve,@companyid) as replacevalveqty,reqvalveavalqty,reqvalveserialno,reqvalverate,dbo.fnGetAvailStockQty(refdetachcoil,@companyid) as reqvalveqty,refdetachcoil,refdeachcoilrate,dbo.fnGetAvailStockQty(reqdetachcoil,@companyid) as reqdetachcoilqty,reqdetachcoil,dbo.fnGetAvailStockQty(woitemcode,@companyid)as reqqty,woitemrate,dbo.fnGetAvailStockQty(selectvalve,@companyid) as replaceselectvalve,selectvalveslno,selectvalve,selectvalverate,dbo.fnGetAvailStockQty(refvalvecoil,@companyid) as selectvalveqty,refvalvecoil,refserialno,refvalverate from tblCoilConversion  where conversionno=@ocno and companyid=@companyid 
end
End
Posted 22-Sep-12 20:16pm
Edited 22-Sep-12 20:24pm
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

exception(DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'itemno')
This simply means that the dataset you tried to bind with your grid does not have any column with name 'itemno'. You need to make sure that the field exists in the query result that you used to bind with the grid.
 
DataKeyNames="itemno" : This is missing the result. Since you have set it as DataKeyNames, so you need to make sure it is a unique for all the records.
  Permalink  
Comments
Member 9345484 at 23-Sep-12 3:40am
   
Ya Sandeep itemno is unique for all the records

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 mhegazy94 460
1 Sergey Alexandrovich Kryukov 430
2 Ravi Bhavnani 190
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,135
1 OriginalGriff 6,801
2 CPallini 5,350
3 George Jonsson 3,619
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 23 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100