I have a obout grid in which right now i have included only one column.When I set the datasource and data bind it the grid shows as empty at runtime.I was doing it with the normal gridview(asp) earlier and it was working fine.I replaced the normal gridview with the obout - now its coming as empty.
<obout:Grid ID="gvReport" runat="server" Serialize="false" ShowTotalNumberOfPages="false" AllowPaging="true"
ShowLoadingMessage="false" FolderStyle="~/styles/premiere_blue" AllowPageSizeSelection="false" EnableRecordHover="true"
AllowGrouping="false" AutoGenerateColumns="false" AllowFiltering="false" FilterType="ProgrammaticOnly"
AllowAddingRecords="false" AllowColumnReordering="false" AllowRecordSelection="true" AllowMultiRecordSelection="true" ShowRecordsPerPage="false" AllowColumnResizing="true" ShowColumnsFooter="false" ShowHeader="true" ShowFooter="true" AllowSorting="true" GenerateRecordIds="True" ViewStateMode="Inherit" KeepSelectedRecords="true" CallbackMode="false"
EmbedFilterInSortExpression="true" Width="100%" PageSize="10" OnRowDataBound="GridView_RowDataBound" OnDataBound="GridView_DataBound" OnDataSourceNeeded="GridDataSourceNeededEvent">
<ScrollingSettings ScrollHeight="260" EnableVirtualScrolling="true" UsePagingForVirtualScrolling="true" /><Columns>
<obout:Column ID="colName" DataField="Name" Width="200px" Wrap="true" HeaderText="Content Name"
ShowFilterCriterias="false">
<TemplateSettings FilterTemplateId="tplNameFilter" />
<FilterOptions>
<obout:FilterOption IsDefault="true" Type="Contains" />
</FilterOptions>
</obout:Column>
</Columns>
<Templates>
<obout:GridTemplate runat="server" ID="tplNameFilter" ControlID="NameFilter">
<Template>
<obout:OboutTextBox runat="server" ID="NameFilter" Width="100%">
</obout:OboutTextBox>
</Template>
</obout:GridTemplate>
</Templates>
<TemplateSettings HeadingTemplateId="tplHeading" />
<PagingSettings PageSizeSelectorPosition="Bottom" Position="Bottom" ShowRecordsCount="True" />
<FilteringSettings InitialState="Hidden" FilterPosition="Top" FilterLinksPosition="Top" />
</obout:Grid>
Code:
gvReport.DataSource = reportData;
gvReport.DataBind();
While debugging the table has all the values but they are not getting assigned to the grid.Previously in place of obout I had normal gridview and it was working fine.
You must remove
OnDataSourceNeeded="GridDataSourceNeededEvent"
you can't have an OnDataSourceNeeded event togheter with gvReport.DataSource
Related
I new to telerik and fighting my way up the learning curve.
I have a RadGrid that I'm populating with a linq query. I'm using a
GridTemplateColumn with a ComboBox for new and edit of one of the fields. The problem is the ComboBox doesn't show on the insert or edit screen. The fields set as GridDropDownColumn do show on the insert or edit. I need GridTemplateColumn solution because I need to run some code once the dropdown list has been selected.
What am I missing here? I'm trying to work from a Telerik example. It's the Release field that is giving me the problem.
<telerik:RadGrid RenderMode="Lightweight" ID="grdData" runat="server"
AllowPaging="true"
AllowSorting="true"
AutoGenerateColumns="false"
AllowAutomaticInserts="true"
AllowAutomaticUpdates="true"
OnNeedDataSource="grdData_OnNeededDataSource"
OnItemDataBound="grdData_OnItemDataBound"
OnUpdateCommand="grdData_OnUpdateCommand" >
<ClientSettings>
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<SelectedItemStyle BackColor="LightYellow" />
<MasterTableView Width="100%"
DataKeyNames="TID"
EditMode="EditForms"
AutoGenerateColumns="false"
InsertItemDisplay="Top"
CommandItemDisplay="Top"
InsertItemPageIndexAction="ShowItemOnFirstPage">
<Columns>
<telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="TID" UniqueName="TID"
HeaderText="TID" ReadOnly="true"></telerik:GridBoundColumn>
<telerik:GridDropDownColumn UniqueName="Employee" ListDataMember="Employee"
SortExpression="Employee" ListTextField="Employee" ListValueField="Employee"
HeaderText="Employee" DataField="Employee"
DropDownControlType="RadComboBox"
EnableEmptyListItem="true" EmptyListItemText="Make a choice" EmptyListItemValue=""
/>
<telerik:GridDropDownColumn UniqueName="Job" ListDataMember="Job"
SortExpression="Job" ListTextField="Job" ListValueField="Job"
HeaderText="Job" DataField="Job"
DropDownControlType="RadComboBox"
EnableEmptyListItem="true" EmptyListItemText="Make a choice" EmptyListItemValue=""
/>
<telerik:GridTemplateColumn UniqueName="Release"
HeaderText="Release"
HeaderStyle-HorizontalAlign="Center"
SortExpression="Release"
ItemStyle-Width="170px" HeaderStyle-Width="80px"
DataField="Release" >
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "Release")%>
</ItemTemplate>
<telerik:EditItemTemplate>
<telerik:RadComboBox runat="server" ID="rcbRelease"
AutoPostBack="true"
EnableLoadOnDemand="true"
DataTextField="Release"
DataValueField="Release"
Text='<% #Bind("Release")%>'
EnableEmptyListItem="true"
EmptyListItemText="Make a choice"
EmptyListItemValue="NR"
OnDataBinding="rcbRelease_OnDataBinding"
></telerik:RadComboBox>
</telerik:EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="ComponentJob" UniqueName="ComponentJob" HeaderText="ComponentJob"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Operation" UniqueName="Operation" HeaderText="Operation"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Quantity" UniqueName="Quantity" HeaderText="Quantity"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Priority" UniqueName="Priority" HeaderText="Priority"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Status" UniqueName="Status" HeaderText="Status"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LastEdit" UniqueName="LastEdit" HeaderText="LastEdit"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
I think your having trouble with the ComboBox because you have EnableLoadOnDemand=true but you have not subscribed to the ItemsRequested event. See Load On Demand Overview for details.
Since you mention your new to the controls, you might want to get the ComboBox LoadOnDemand working outside of the grid first.
Try removing the telerik namespace/prefix from the EditItemTemplate declaration:
Change this:
<telerik:EditItemTemplate>
<%-- RadComboBox --%>
</telerik:EditItemTemplate>
To this:
<EditItemTemplate>
<%-- RadComboBox --%>
</EditItemTemplate>
Also, please share with us which documentation were you following so that we can double check and report the documentation error.
I have below GridView with radio button as column. I want to hide or display panel based on GridView row selection that will be rendering outside of GridView in same page.
Below is my GridView:
<table style="width: 95%; margin-top: 10px;" class="transferCertsTbl">
<tr style="width: 95%">
<td colspan="2">
<asp:GridView ID="gvClearpassCertInfo" runat="server" AutoGenerateColumns="False" GridLines="None"
CellSpacing="1" CellPadding="1"
Width="95%" BorderWidth="0"
AllowSorting="True"
PageSize="30"
OnRowDataBound="gvClearpassCertInfo_RowDataBound"
CssClass="data responsive">
<Columns>
<asp:TemplateField HeaderText="Select" SortExpression="">
<ItemTemplate>
<asp:RadioButton ID="radioChkCert" runat="server" onclick="RadioCheck(this);" /><input type="hidden" id="hdnCertId" runat="server" value='<%# DataBinder.Eval(Container.DataItem, "CertId") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CertificateID" HeaderText="Certificate ID" HeaderStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="partID" HeaderText="Part Number" HeaderStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="BaseLicense" HeaderText="Base License" Visible="false" />
</Columns>
<EmptyDataRowStyle CssClass="AlternatingRowStyle" />
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center" />
<RowStyle HorizontalAlign="Center" />
<AlternatingRowStyle HorizontalAlign="Center" />
<PagerSettings Visible="False" />
</asp:GridView>
</td>
</tr>
</table>
But I am not sure how to display or hide based on row selection in GridView on server side only.
Could any one please help on this that would be very grateful to me?
You can do the following:
For the radio button tag add autopostback=true and OnCheckedChanged="radioChkCert_CheckedChanged" like this:
<asp:RadioButton ID="radioChkCert" runat="server" onclick="RadioCheck(this);" autopostback="true" OnCheckedChanged="radioChkCert_CheckedChanged"/>
in the codebehind add the function:
protected void radioChkCert_CheckedChanged(object sender, EventArgs e)
{
radiobutton radiobtn = (radiobutton)sender;
string txt = (((Label)radiobtn.Parent.FindControl("l1")).Text); //l1 is the id of a label in the gridview
if ((txt == "CertainCode")) {
Certainpanel.Visible = true;
}
}
Note:
I used the label's text to control which panel to show, in your case choose it depending on which control and it's value.
I converted from vb.net to C# tell me if there is an error
I am retrieving data from database using RadGrid. I have more columns in my RadGrid, so I need to show RadGrid horizontal scroll to keep the page from expanding but disable the vertical scroll so height of the grid should expand to always display all rows in the grid. I got the result but there is whitespace in the bottom of the RadGrid.
My UI of the RadGrid:
<table style="table-layout: fixed;" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="false" PagerStyle-AlwaysVisible="true"
CellPadding="0" CellSpacing="0" GridLines="None" Skin="Metro" CssClass="RadGrid_CBGrid"
HorizontalAlign="Left" AutoGenerateColumns="False" OnItemCommand="RadGrid1_ItemCommand"
OnDataBound="RadGrid1_DataBound">
<ClientSettings>
<Selecting CellSelectionMode="SingleCell"></Selecting>
<Scrolling AllowScroll="true" UseStaticHeaders="True"></Scrolling>
</ClientSettings>
<MasterTableView HierarchyLoadMode="Client" DataKeyNames="EmpID" AllowMultiColumnSorting="true"
Name="Parent">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="EmpID" EmptyDataText="NA" HeaderText="Emp ID"
UniqueName="EmpID">
</telerik:GridBoundColumn>
and so on......
-------------------
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
</telerik:RadGrid>
</td>
</tr>
</table>
If I changed ClientSettings-Scrolling-AllowScroll="true" in RadGrid and
I got the result and there is NO whitespace in the bottom of the RadGrid BUT Horizontal scroll bar is NOT coming in my RadGrid.
So can anybody please give me the solution.
Or if you don't want to worry about hieght calculation do this!
// radgrid scroll horizontal only
<ClientSettings AllowDragToGroup="True" AllowGroupExpandCollapse="true">
<Scrolling AllowScroll="true" />
<ClientEvents OnGridCreated="GridCreated" />
</ClientSettings>
function GridCreated(sender, args) {
$('.rgDataDiv').removeAttr('style');
$('.rgDataDiv').attr('style', 'overflow-x: scroll;');
}
Just change overflow-x property value of data grid to scroll , instead of applying auto. If you have this issue in IE9.
.NET 4 ASP.NET
I have a DetailsView that is displaying an entity framework record for a table that has a linked lookup table. I have an asp:BoundField with the datafield set as "linkedTable.Field" and it displays a value.
<asp:BoundField DataField="linkedTable.Field" HeaderText="linkedTable.Field"
SortExpression="linkedTable.Field" />
I am trying to use that value in an asp:TemplateField but when I try to get it using:
<asp:TemplateField HeaderText="Field" SortExpression="linkedTable.Field" >
<EditItemTemplate>
<asp:Label runat="server" ID="lblField" Text='<%# Bind("linkedTable.Field") %>' />
</EditItemTemplate>
</asp:TemplateField>
Nothing shows up in the label. I can change the Bind() to a field that is not part of the linked table and it works (i.e. the "ID" field). My problem is I don't understand why the linkedtable.Field value shows up in one context and not in the other.
FYI, my data connection is a EntityDataSource
<asp:EntityDataSource ID="edsNYSEDaily" runat="server"
ConnectionString="name=ServerDBEntities"
DefaultContainerName="ServerDBEntities" EntitySetName="tblNYSE"
EntityTypeFilter="tblNYSE" EnableUpdate="True" EnableFlattening="true"
AutoGenerateWhereClause="True" Select="" Where="">
<WhereParameters>
<asp:QueryStringParameter DefaultValue="0" Name="ID"
QueryStringField="ID" Type="Int32" />
</WhereParameters>
Let me know if you need any other information. I am stuck
Ok, discovered the problem:
Needed to add Include="linkedTable" to the EntityDataSource tag. Still not sure why it was even working in the <asp:DataBound /> tag.
Source for the answer: forums.asp.net
Copy of the text:
you should start here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.entitydatasource.include.aspx
notice that, you won't be able to Bind (I mean two-way data-binding) the related entities (see the remarks there).
and, you'd have to use a TemplateField for those properties.
see this example (I used the link table 'TableAB' for EntitySetName and included the other two):
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="EntityDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="IDA" HeaderText="IDA" SortExpression="IDA" />
<asp:BoundField DataField="IDB" HeaderText="IDB" SortExpression="IDB" />
<asp:TemplateField HeaderText="TableA Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("TableA.NameA") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TableB Name">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("TableB.NameB") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=ABLinkEntities"
DefaultContainerName="ABLinkEntities" EnableDelete="True" EnableFlattening="False"
EnableInsert="True" EnableUpdate="True" EntitySetName="TableABs" Include="TableA,TableB">
</asp:EntityDataSource>
you'll have to re-consider the updates and deletes, you could do them manually.
I have a list of objects called Activity and I want to display the date, type and notes for each and every one of these activities. This is the code I'm using.
<asp:GridView ID="gvTable" runat="server" AllowSorting="true" ShowHeader="true">
<Columns>
<asp:BoundField DataField="ActivityDate" HeaderText="Date"
HeaderStyle-CssClass="date" />
<asp:BoundField DataField="ActivityType" HeaderText="Type" />
<asp:BoundField DataField="ActivityNotes" HeaderText="Notes" />
</Columns>
<PagerSettings Position="Bottom" Mode="NextPrevious" PageButtonCount="5"
PreviousPageText="Older activities" NextPageText="Newer activities" />
</asp:GridView>
However, all of the attributes of each object is displayed in the header. How can I force it to display only the columns that I want to use?
gvTable.AutoGenerateColumns = false
or
<asp:GridView ID="gvTable" runat="server" AutoGenerateColumns="False" AllowSorting="true" ShowHeader="true">
should do the trick.
Set the attribute on your gridview:
AutoGenerateColumns="false"
You need to set the AutoGenerateColumns property on the grid to false.
Have you tried AutoGenerateColumns="false" in the gridview?