<div id="divErrorCount" runat="server" class="page">
<asp:GridView ID="gvsummary" runat="server" AutoGenerateColumns="False" CellPadding="0"
Width="940px" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
Font-Bold="True" ForeColor="Black" Style="text-align: center">
<Columns>
<asp:TemplateField HeaderText="Unproductive Reason">
<ItemTemplate>
<asp:Label ID="lblunprodreasons" runat="server" Text='<%# Bind("unprodreasons") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Count">
<ItemTemplate>
<asp:Label ID="lblCount" runat="server" Text='<%# Bind("Count") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#CCCCCC" />
</asp:GridView>
</div>
代碼隱藏:名稱「gvMyDetails」不會在目前情況下(asp.net,C#)存在的幫助,請
divErrorCount.Visible = true;
SqlDataReader myReader3 = null;
SqlCommand myCommand3 = new SqlCommand("SELECT unprodreasons, COUNT(unprodreasons) as Count FROM [myrecords] where username = '" + ddlrep.SelectedValue.Trim() + "' and (dates >= '" + datefrom + "' and dates <= '" + dateto + "') group by unprodreasons", myConnection);
myReader3 = myCommand3.ExecuteReader();
//myReader3.Read();
if (myReader3.HasRows)
{
gvsummary.DataSource = myReader3;
gvsummary.DataBind();
myReader3.Close();
}
else
{
myReader3.Close();
//divErrorCount.Visible = false;
}
-1沒有照顧你自己的問題(沒有格式化,沒有解釋)。 – 2012-07-10 16:38:19
代碼轉儲中不存在名稱'gvMyDetails'。錯誤發生在哪裏?發佈相關代碼。 – LittleBobbyTables 2012-07-10 16:38:22
那麼,_does_它存在嗎?它沒有提到你已經發布的任何代碼。 – David 2012-07-10 16:38:51