属性在gridview的标签上保持显示0 [英] Property keeps displaying 0 on label in gridview

查看:81
本文介绍了属性在gridview的标签上保持显示0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个gridview,并且其中有一个包含很多控件的模板.除lblQty我尝试过的所有内容外,所有标签均显示正确的值,但它仅显示0,在某些情况下不是正确的值.这是Gridview的示例代码

Hi
I have a gridview and within it I have a template holding lots of controls. All labels display the correct value except for lblQty I''ve tried everything but it just displays 0 in which in some cases is not the correct value. heres the sample code of the Gridview

<asp:GridView ID="GrdJobSht" runat="server" AutoGenerateColumns="False"DataSourceID="GetJobSheetDATA">
 <Columns>
  <asp:TemplateField>
    <ItemTemplate>  
     <table>
     <tr><td rowspan="5" class="style4">
<asp:Image ID="ProdImage" runat="server" Height="152px" 

 ImageUrl='<%# String.Format(ResolveUrl("ProductImage.ashx")+"{0}{1}","?id=",Eval("propImageId")) %>'

 style="margin-left: 0px" Width="172px" BorderColor="Silver" 

 BorderStyle="Double" BorderWidth="10pt" /> 
 </td></tr><tr><td class="style5">
<asp:Label ID="Label1" runat="server" Text="Product ID:" Font-Italic="True" 

             Font-Names="Times New Roman" Font-Size="Medium"></asp:Label>
</td><td>
 <asp:Label ID="lblProdid" runat="server" Text='<%# Eval("propProdId") %>'></asp:Label>
</td></tr><tr><td class="style5">
 <asp:Label ID="Label2" runat="server" Text="Description:" Font-Italic="True" 

      Font-Names="Times New Roman" Font-Size="Medium"></asp:Label>
 </td><td>
  <asp:Label ID="lblDesc" runat="server" Text='<%# Eval("propProdDesc") %>'></asp:Label>
 </td></tr><tr><td class="style5">
 <asp:Label ID="Label3" runat="server" Text="Quantity:" Font-Italic="True" 

 Font-Names="Times New Roman" Font-Size="Medium"></asp:Label>
 </td><td>
 <asp:Label ID="lblQty" runat="server" Text= '<%# Eval("propProdQty") %>'></asp:Label>//This returns 0 I do not know why maybe its because its an Int
</td></tr><tr><td class="style5">
<asp:Label ID="Label4" runat="server" Text="Colour:" Font-Italic="True" 

   Font-Names="Times New Roman" Font-Size="Medium"></asp:Label>
</td><td>
 <asp:Label ID="lblColor" runat="server" Text='<%# Eval("propColour") %>'></asp:Label>
</td></tr><tr><td class="style5">
<asp:Label ID="Label5" runat="server" Text="Def Design:" Font-Italic="True" 

 Font-Names="Times New Roman" Font-Size="Medium"></asp:Label>
</td><td>
 <asp:Label ID="lblDefDes" runat="server" Text='<%# Eval("propDeflectionDesign") %>'></asp:Label>

</td></tr></table>                                                                        
</ItemTemplate>
 </asp:TemplateField>
  <asp:TemplateField>
   <ItemTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="obsMeas">
 <Columns>
<asp:BoundField DataField="propWidth" HeaderText="propWidth" SortExpression="propWidth" />
<asp:BoundField DataField="propHeight" HeaderText="propHeight" SortExpression="propHeight" />
<asp:BoundField DataField="ProprodId" HeaderText="ProprodId" SortExpression="ProprodId" />
 </Columns>
</asp:GridView>
<asp:ObjectDataSource ID="obsMeas" runat="server" SelectMethod="getProdMeasurements" TypeName="BusinessLogicLayer.Measurements">
 <SelectParameters>
<asp:ControlParameter ControlID="DDlQno" Name="qno" PropertyName="SelectedValue" Type="Int32" />
<asp:ControlParameter ControlID="lblProdid" Name="id" PropertyName="Text" Type="string" />
 </SelectParameters>
 </asp:ObjectDataSource>
   </ItemTemplate>
    </asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="GetJobSheetDATA" runat="server" SelectMethod="GetJobSheet" TypeName="BusinessLogicLayer.QuoteProduct">
 <SelectParameters>
<asp:ControlParameter ControlID="DDlQno" DefaultValue="129126" Name="Qno" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>



问候
在Advance中致谢



Regards
Thanks in Advance

推荐答案

从您提供的内容来看,这是我现在能给您的最好的答案.

1)您需要在收集数据的地方调试代码,并确保数据中的字段值开头正确.
2)确保您的值< code> propProdQ​​ty</code>的拼写正确.正确地用正确的大小写拼写,并且在前面也没有错.
From what you have provided, this is about the best I can give you right now.

1) You need to debug your code behind where you collect the data and ensure that the field value in the data is correct to start with.
2) Ensure that the spelling of your value <code>propProdQty</code> is spelled correctly with correct casing and that nothing is wrong on that front either.


这篇关于属性在gridview的标签上保持显示0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆