When the page loads the "No data found" message appears.
If set AutogenerateColumns = true then data appears.
Why does no data appear when explicitly creating columns?
If set AutogenerateColumns = true then data appears.
Why does no data appear when explicitly creating columns?
<telerik:RadGrid |
ID="RadGrid1" |
runat="server" |
AllowPaging="true" |
AutoGenerateColumns="false"> |
<telerik:MasterTableView TableLayout="Auto"> |
<Columns> |
<telerik:GridBoundColumn |
DataField="Name" |
DataType="System.String" |
HeaderText="Name" |
SortExpression="Name" |
UniqueName="Name"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn |
DataField="Description" |
DataType="System.String" |
HeaderText="Description" |
SortExpression="Description" |
UniqueName="Description"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn |
HeaderText="Status"> |
<ItemTemplate> |
<%# (Boolean.Parse(Eval("IsDeleted").ToString())) ? "Deleted" : "Active" %> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
</telerik:MasterTableView> |
</telerik:RadGrid> |
protected void Page_Load(object sender, EventArgs e) |
{ |
ReportManager mgr = Global.Container.Resolve<ReportManager>(); |
IList<ServerReport> reports = mgr.GetAllReports(); |
RadGrid1.DataSource = reports; |
//grdvwReportList.DataSource = reports; |
//grdvwReportList.DataBind(); |
} |
11 Answers, 1 is accepted
0
Hi Ryan,
Try using Advanced databinding for your gird as opposed to Simple databingind.
Greetings,
Tsvetoslav
the Telerik team
Try using Advanced databinding for your gird as opposed to Simple databingind.
Greetings,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ryan
Top achievements
Rank 1
answered on 25 Jun 2010, 10:32 AM
Hi
Ok, so I moved the code into the NeedDataSource event handler, but still no data is displayed.
I think I followed the instructions correctly. But I cannot see what I've done wrong.
Ok, so I moved the code into the NeedDataSource event handler, but still no data is displayed.
I think I followed the instructions correctly. But I cannot see what I've done wrong.
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
{ |
ReportManager mgr = Global.Container.Resolve<ReportManager>(); |
IList<ServerReport> reports = mgr.GetAllReports(); |
RadGrid1.DataSource = reports; |
} |
0
Hello Ryan,
There is nothing wrong with the code-snippets you have pasted. Is it possible that you open up a formal support ticket and send a small test project for inspection. This will also guarantee you a faster repsonse time within 24 hours. Thanks in advance.
Regards,
Tsvetoslav
the Telerik team
There is nothing wrong with the code-snippets you have pasted. Is it possible that you open up a formal support ticket and send a small test project for inspection. This will also guarantee you a faster repsonse time within 24 hours. Thanks in advance.
Regards,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
John
Top achievements
Rank 1
answered on 01 Jul 2010, 03:15 PM
I'm actually having a very similar problem. I have a grid on one page that binds using the NeedDataSource event, it uses Master and Detail grids. On another page i'm just using NeedDataSource to load one grid(no subs), the code and return types of the functions are identical to the Master/Detail grid (DataView). But the single grid always shows the no rows message. I've verified that the DataView i'm assigning to the grid.DataSource property has data, and that the DataSource property shows the data in it before the event finishes. When i step through the code the ItemDataBound event only runs for a pager, header, and footer when there should be a dozen or so rows.
If i bind the grid using simple data binding it works fine, when i use working code from my Master/Detail page on the single page(i omitted the parts about binding the detail grid) it shows no data. It also throws no errors of any kind. Was there a solution found to the OP's problem?
I'm using version 2010.1.415.20, could this be a bug fixed in the current version?
Any insight would be appreciated
John
If i bind the grid using simple data binding it works fine, when i use working code from my Master/Detail page on the single page(i omitted the parts about binding the detail grid) it shows no data. It also throws no errors of any kind. Was there a solution found to the OP's problem?
I'm using version 2010.1.415.20, could this be a bug fixed in the current version?
Any insight would be appreciated
John
0
Ryan
Top achievements
Rank 1
answered on 01 Jul 2010, 03:20 PM
Hi John
It's not a bug. I am using the same version as you. My issue was fixed (thanks to Telerik support) by using
instead of
Hope this helps.
It's not a bug. I am using the same version as you. My issue was fixed (thanks to Telerik support) by using
<MasterTableView> |
instead of
<telerik:MasterTableView> |
Hope this helps.
0
John
Top achievements
Rank 1
answered on 01 Jul 2010, 03:22 PM
Thanks for the help, I'm already using <MasterTableView>, was there anything else they suggested you change?
John
John
0
Ryan
Top achievements
Rank 1
answered on 01 Jul 2010, 03:30 PM
No, but if you post some code I (or someone else) may be able to help.
0
John
Top achievements
Rank 1
answered on 01 Jul 2010, 03:38 PM
<telerik:RadGrid ID="dgListData" AllowCustomPaging="false" |
runat="server" AllowSorting="true" AutoGenerateColumns="false" |
CellPadding="0" CellSpacing="0" OnNeedDataSource="dgListData_NeedDataSource" |
onitemcommand="dgListData_ItemCommand" OnPageIndexChanged="dgListData_PageChanged" |
onitemdatabound="dgListData_ItemDataBound" onsortcommand="dgListData_SortCommand" |
AllowAutomaticDeletes="false" AllowAutomaticInserts="false" |
AllowAutomaticUpdates="false" AllowMultiRowEdit="false" AllowMultiRowSelection="true"> |
<ClientSettings EnableAlternatingItems="true" EnableRowHoverStyle="true"> |
<ClientEvents OnPopUpShowing="PopUpCentered" /> |
<Selecting AllowRowSelect="true" EnableDragToSelectRows="true" /> |
</ClientSettings> |
<SelectedItemStyle HorizontalAlign="Center" VerticalAlign="Middle"/> |
<MasterTableView Width="575px" AutoGenerateColumns="false" DataKeyNames="uniqueId" AllowMultiColumnSorting="true" |
AllowNaturalSort="true" OverrideDataSourceControlSorting="true" DataMember="ListData" |
RowIndicatorColumn-Display="true" RowIndicatorColumn-ShowSortIcon="true" EditMode="PopUp" AllowCustomPaging="false" AllowPaging="true"> |
<HeaderStyle HorizontalAlign="Center"></HeaderStyle> |
That is my grid declaration, everything past that is just a custom edit form and colums...both of which worked fine before NeedDataSource and are more numerous but identical to the definitions in my Master/Detail grid.
Here is the simple NeedDataSource event, followed by the bindGrid function. bind Grid is never called from anywhere other than NeedDataSource, and ReBind is never used either. i may need to use it later, but right now my problem is with the initial page load.
protected void dgListData_NeedDataSource (object source, GridNeedDataSourceEventArgs e) |
{ |
dgListData.DataSource = bindGrid(); |
} |
protected DataView bindGrid () |
{ |
int start = 0; |
string sql = ""; |
DataSet ds = new DataSet(); |
DataRow row = null; |
DataTable table = new DataTable(); |
SqlDataAdapter myCommand = null; |
try |
{ |
sql = lblQuery.Text + lblSearch.Text; |
myConnection.Open(); |
myCommand = new SqlDataAdapter(sql, myConnection); |
myCommand.SelectCommand.CommandTimeout = 240; |
myCommand.Fill(ds, "ListData"); |
source = ds.Tables["ListData"].DefaultView; |
//sorty stuff |
//if (dgListData.MasterTableView.SortExpressions.Count == 0) |
//{ |
// source.Sort = lblSort.Text; |
//} |
//else |
//{ |
//} |
//Adjust the size displayed in the header. |
lst.ListSize = source.Count; |
lblListName.Text = lst.ListName; |
if (lst.International) |
{ |
lblListName.Text += " (International List)"; |
} |
//dgListData.DataSource = source; |
//dgListData.DataBind(); |
} |
catch (Exception ex) |
{ |
Trace.Write("", "bindGrid() - ", ex); |
} |
finally |
{ |
if (myCommand != null) |
{ |
myCommand.Dispose(); |
} |
if (ds != null) |
{ |
ds.Dispose(); |
} |
if (source != null) |
{ |
source.Dispose(); |
} |
myConnection.Close(); |
} |
return source; |
}//end bind grid |
If theres any other code you need let me know, there arent any exceptions bieng throwin in ItemDataBound, and i just do a little formatting in that function anyway. It also only gets called with Pager Header and Footer item types, even though the DataSource has rows in it.
0
Ryan
Top achievements
Rank 1
answered on 01 Jul 2010, 03:58 PM
The problem may not be in the MasterTableView (I can't see anything obvious anyway). So ideally, it would be nice to see the whole RadGrid.
0
John
Top achievements
Rank 1
answered on 01 Jul 2010, 06:28 PM
<PagerStyle AlwaysVisible="false" Position="Top" PageSizeLabelText="" Mode="NextPrevAndNumeric" |
PagerTextFormat="{4} Total records: <strong>{5}</strong>" /> |
<Columns> |
<telerik:GridTemplateColumn HeaderText="Cat." UniqueName="Category" SortExpression="CategoryId"> |
<HeaderStyle Width="18px" /> |
<ItemStyle Width="18px" /> |
<ItemTemplate><asp:ImageButton CommandName="Color" ToolTip='<%# DataBinder.Eval( Container, "DataItem.Description")%>' |
CommandArgument='<%# DataBinder.Eval( Container, "DataItem.CategoryId")%>' runat="server" ID="ibtnCategory" |
ImageUrl='<%#"../images/icons/" + DataBinder.Eval(Container,"DataItem.ImageName")%>' Width="16px" Height="16px" /></ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridEditCommandColumn ButtonType="LinkButton" HeaderText="Edt" |
EditText="<img src='../images/Icons/icon_edit.gif' width='16' height='16' alt='Edit This Record' border='0'>"> |
<HeaderStyle ForeColor="Black" width="18px"></HeaderStyle> |
<ItemStyle HorizontalAlign="Center" Width="18px"></ItemStyle> |
</telerik:GridEditCommandColumn> |
<telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" SortExpression="LastName" HtmlEncode="true"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" HtmlEncode="true"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Number" HeaderText="Number" SortExpression="Number" HtmlEncode="true"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Email" HeaderText="Email" SortExpression="Email"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field1" HeaderText="" SortExpression="Field1" Visible="false" HtmlEncode="true"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field2" HeaderText="" SortExpression="Field2" Visible="false" HtmlEncode="true"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field3" HeaderText="" SortExpression="Field3" Visible="false" HtmlEncode="true"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field4" HeaderText="" SortExpression="Field4" Visible="false" HtmlEncode="true"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field5" HeaderText="" SortExpression="Field5" Visible="false" HtmlEncode="true"></telerik:GridBoundColumn> |
<telerik:GridTemplateColumn HeaderText="Del" UniqueName="Delete"> |
<HeaderStyle ForeColor="Black"></HeaderStyle> |
<ItemStyle HorizontalAlign="Center"></ItemStyle> |
<ItemTemplate> |
<asp:imagebutton id="btnDelete" runat="server" alternatetext="Delete This Row" commandname="Delete" height="16px" |
imageurl="../images/icons/icon_delete.gif" width="16px"></asp:imagebutton> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
</MasterTableView> |
The Edit form was omitted for readability, it shouldnt be involved in anything during page load anyway. The headertext for Field 1-5 would be set in the ItemDataBound event, if it ever got called for a data row.
0
Hello John,
I think you are assigning the grid an already disposed of DataView object. The finally code block runs before the return of the DataView has been reached, doesn't it? And it is in the finally where you are disposing the DataView and the DataSet.
Best wishes,
Tsvetoslav
the Telerik team
I think you are assigning the grid an already disposed of DataView object. The finally code block runs before the return of the DataView has been reached, doesn't it? And it is in the finally where you are disposing the DataView and the DataSet.
Best wishes,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items