Help Datagrid always displayed as disabled

  • Thread starter Thread starter brian richards
  • Start date Start date
B

brian richards

The datagrid in my page always looks greyed out. But DataGrid.Enabled is set
to true. It's never set to false. Is there any other way enabled may be set
to false? Or maybe another reason other than the Enabled property that would
cause this?

I've included the asp.net code and the C# databind code.

Thanks


///C# Bind code
public void BindGrid()
{
string date = Request["Date"];
if(date!=null && date!="")
{
try
{
this.sqlSelectCommand3.CommandText = "SELECT Date, UsageCharges,
MonthlyCharges, ProratedCharges, "+
"OneTimeCharges, TaxesFSL, OtherTaxesSurcharges, (UsageCharges +
MonthlyCharges + ProratedCharges +"+
"OneTimeCharges + TaxesFSL + OtherTaxesSurcharges) AS Total FROM
tbMonthlyChargeBreakdown WHERE "+
"Date = \'"+DateTime.Parse(date).ToString("yyyyMMdd")+"\'";
sqlDataAdapter3.Fill(dsMonthTable1);
dg_ChrgBreakdown.DataBind();
}
catch(Exception e)
{
Response.Write(e.Message+e.Source+e.StackTrace+"\n"+date);
}
}

/////Asp.net code
<asp:DataGrid id=dg_ChrgBreakdown runat="server" Width="100%"
DataSource="<%# dvMonthTable %>" AutoGenerateColumns="False"
CellPadding="1">
<ItemStyle HorizontalAlign="Right"></ItemStyle>
<HeaderStyle HorizontalAlign="Center" ForeColor="White"
BackColor="#292C8B"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="Date" HeaderText="Date"
DataFormatString="{0:y}">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="UsageCharges"
HeaderText="UsageCharges"
DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
<asp:BoundColumn DataField="MonthlyCharges"
HeaderText="Monthly"
DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
<asp:BoundColumn DataField="ProratedCharges"
HeaderText="Prorated"
DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
<asp:BoundColumn DataField="OneTimeCharges"
HeaderText="One Time"
DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
<asp:BoundColumn DataField="TaxesFSL"
HeaderText="Taxes" DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
<asp:BoundColumn DataField="OtherTaxesSurcharges"
HeaderText="Surcharges"
DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
<asp:BoundColumn DataField="Total"
HeaderText="Total" DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
 
Brian,

Have you created the DataGrid's source by Wizard or by "hand code"? I mean
where was the dvMonthTable created?

Because, I bind the data source a little bit different... like

....
sqlDataAdapter3.Fill(dsMonthTable1);
dg_ChrgBreakdown.DataSource = dsMonthTable1.Tables[0].DefaultView;
dg_ChrgBreakdown.DataBind();
....

I hope help you
Marcos


brian richards said:
The datagrid in my page always looks greyed out. But DataGrid.Enabled is set
to true. It's never set to false. Is there any other way enabled may be set
to false? Or maybe another reason other than the Enabled property that would
cause this?

I've included the asp.net code and the C# databind code.

Thanks


///C# Bind code
public void BindGrid()
{
string date = Request["Date"];
if(date!=null && date!="")
{
try
{
this.sqlSelectCommand3.CommandText = "SELECT Date, UsageCharges,
MonthlyCharges, ProratedCharges, "+
"OneTimeCharges, TaxesFSL, OtherTaxesSurcharges, (UsageCharges +
MonthlyCharges + ProratedCharges +"+
"OneTimeCharges + TaxesFSL + OtherTaxesSurcharges) AS Total FROM
tbMonthlyChargeBreakdown WHERE "+
"Date = \'"+DateTime.Parse(date).ToString("yyyyMMdd")+"\'";
sqlDataAdapter3.Fill(dsMonthTable1);
dg_ChrgBreakdown.DataBind();
}
catch(Exception e)
{
Response.Write(e.Message+e.Source+e.StackTrace+"\n"+date);
}
}

/////Asp.net code
<asp:DataGrid id=dg_ChrgBreakdown runat="server" Width="100%"
DataSource="<%# dvMonthTable %>" AutoGenerateColumns="False"
CellPadding="1">
<ItemStyle HorizontalAlign="Right"></ItemStyle>
<HeaderStyle HorizontalAlign="Center" ForeColor="White"
BackColor="#292C8B"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="Date" HeaderText="Date"
DataFormatString="{0:y}">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="UsageCharges"
HeaderText="UsageCharges"
DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
<asp:BoundColumn DataField="MonthlyCharges"
HeaderText="Monthly"
DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
<asp:BoundColumn DataField="ProratedCharges"
HeaderText="Prorated"
DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
<asp:BoundColumn DataField="OneTimeCharges"
HeaderText="One Time"
DataFormatString="{0:$###,###,###.00}"></asp:BoundColumn>
<asp:BoundColumn DataField="TaxesFSL"
HeaderText="Taxes"
 
The datasource was set in the ASP page.
<asp:DataGrid id=dg_ChrgBreakdown runat="server" Width="100%"
DataSource="<%# dvMonthTable %>" AutoGenerateColumns="False"
CellPadding="1">
I tried
sqlDataAdapter3.Fill(dsMonthTable1);
dg_ChrgBreakdown.DataSource = dsMonthTable1.Tables[0].DefaultView;
dg_ChrgBreakdown.DataBind();
and
sqlDataAdapter3.Fill(dsMonthTable1);
dg_ChrgBreakdown.DataSource = dvMonthTable;
dg_ChrgBreakdown.DataBind();
and
sqlDataAdapter3.Fill(dsMonthTable1);
dvMonthTable.Table = dsMonthTable1.Tables[0];
dg_ChrgBreakdown.DataSource = dvMonthTable;
dg_ChrgBreakdown.DataBind();

But I get the same gray results.

-Brian
 
Back
Top