How I fill combobox items in Radgridview manually without using datasource in vb.net I have a Radgridview in my form.(radgridview1) radgridview1 contained 3 Column and column number 3 is combobox type. I want to fill each combobox in column 3 with this data using code: UNP IPE Angle BOX Other Profile. I don't know how to do it.
You can use GridTemplateColumn like the following.
<telerik:GridTemplateColumn ItemStyle-Wrap="true" ItemStyle-VerticalAlign="Middle"
ItemStyle-HorizontalAlign="center" AllowFiltering="false" HeaderStyle-HorizontalAlign="Center"
HeaderStyle-Width="3%" ItemStyle-Width="3%" HeaderText="Profile">
<ItemTemplate>
<telerik:RadComboBox>
<Items>
<telerik:RadComboBoxItem Text="UNP" Value="UNP" />
<telerik:RadComboBoxItem Text="IPE" Value="IPE" />
<telerik:RadComboBoxItem Text="ANGLE" Value="ANGLE" />
<telerik:RadComboBoxItem Text="BOX" Value="BOX" />
<telerik:RadComboBoxItem Text="Other Profile" Value="OTHER" />
</Items>
</telerik:RadComboBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
or else you can bind each comboBox in _ItemDataBound
Related
I have a page where I search the data and populate RadGrid.
The page has a button to export the data into Excel.
Everything works fine, data is exporting. I can search as well.
I hide the button and RadGrid in the code when the Grid is empty:
btnExport.Visible = false;
gridDisplay.Visible = false;
However, when RadGrid is empty, it becomes hidden but button is still displayed.
I build the RadGrid inside of the RadAjaxPanel:
<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" LoadingPanelID="RadAjaxLoadingPanel2">
<telerik:RadGrid
RenderMode="Lightweight"
runat="server"
ID="grdMoss2Merchants"
AllowPaging="True"
AllowSorting="true"
PagerStyle-AlwaysVisible="true"
OnNeedDataSource="BindToDatasource"
OnSortCommand="grdMoss2Merchants_SortCommand"
ViewStateMode="Enabled"
AutoGenerateColumns="false"
OnPageIndexChanged="grdMoss2Merchants_ChangePage"
ClientSettings-Scrolling-ScrollHeight="360px">
<GroupingSettings CaseSensitive="false"/>
<ExportSettings HideStructureColumns="true" ExportOnlyData="true" OpenInNewWindow="true" Excel-Format="Xlsx" IgnorePaging="true" FileName="Moss2Merchants">
<Excel WorksheetName="Moss2Merchants" Format="Xlsx" AutoFitColumnWidth="AutoFitAll" />
</ExportSettings>
<ClientSettings EnableRowHoverStyle="true">
<Scrolling AllowScroll="true" UseStaticHeaders="True"/>
<ClientEvents OnKeyPress="keyPress" />
</ClientSettings>
<SortingSettings EnableSkinSortStyles="false" />
<HeaderStyle Width="160px" CssClass="grdHeader" ForeColor="#2E6E9E" />
<MasterTableView AllowNaturalSort="false">
<PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" PageSizes="10,25,50,100" />
<Columns>
<telerik:GridBoundColumn DataField="Moss2 MID" HeaderText="MOSS2 MID" AllowSorting="false" DataFormatString="{0:#}"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="DBA" HeaderText="DBA" HeaderStyle-Width="250px">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Original MID" HeaderText="ORIGINAL MID" AllowSorting="false" DataFormatString="{0:#}"></telerik:GridBoundColumn>
<telerik:GridBoundColumn
DataField="BoardingDate"
DataType="System.DateTime"
HtmlEncode="false"
DataFormatString="{0:MM/dd/yyyy}"
SortExpression="BoardingDate"
UniqueName="BoardingDate"
HeaderText="BOARDING DATE"
HeaderStyle-Width="170px"
ShowFilterIcon="false"
/>
<telerik:GridBoundColumn DataField="Status" HeaderText="STATUS" AllowSorting="false"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
</telerik:RadAjaxPanel>
This just a simple code to generate a button outside of the Grid:
<div>
<telerik:RadButton ID="btnExport" runat="server" OnClick = "btnExportClick" Text="Export To Excel" CausesValidation="false"/>
<br/>
</div>
I'm not sure what I'm doing wrong here.
Need some assistance
I am working with telerik, and want to export data from radgrid in my vb.net web application. After filter grid, when click on export button, nothing works and itemCommand header(refresh button, export buttons) hide automatically.
But export grid without filter , working perfectly.
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="radgrid1_NeedDataSource" ShowStatusBar="true" AllowPaging="True" Skin="Windows7" AllowCustomPaging="false" PageSize="25" GridLines="None" AutoGenerateColumns="false" AllowSorting="true" AllowColumnResize="true">
<PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
<MasterTableView Width="100%" CommandItemDisplay="Top" ShowHeader="true">
<Columns>
<telerik:GridBoundColumn DataField="assettagnumber" HeaderText="Tag Number" SortExpression="assettagnumber" UniqueName="assettagnumber">
<HeaderStyle Width="80px" />
</telerik:GridBoundColumn>
</Columns>
<CommandItemSettings ShowExportToWordButton="true" ShowAddNewRecordButton="false" ShowExportToExcelButton="true" ShowExportToPdfButton="false" ShowExportToCsvButton="true" />
</MasterTableView>
<ExportSettings IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true">
</ExportSettings>
<ClientSettings>
<Scrolling AllowScroll="True" EnableVirtualScrollPaging="false" SaveScrollPosition="True" UseStaticHeaders="True" />
</ClientSettings>
</telerik:RadGrid>
I want to export filtered grid data.
Please tell me the possible solution.
Thanks..
Dim pctofpax As New DataColumn
pctofpax = New DataColumn("PCTPAX1", GetType(Decimal))
pctofpax.Expression = "[ASOFPAX] / [YEPAX]"
ds.Tables("workplease").Columns.Add(pctofpax)
Dim avgppax As New DataColumn
avgppax = New DataColumn("AVG PAX", GetType(Double))
avgppax.Expression = "[Current Sales] / [Current PAX]"
ds.Tables("workplease").Columns.Add(avgppax)
These are two columns that i added into my asp.net/vb.net datagrid. the problem is i keep trying to change the datatypes so they show up as numbers with only two decimals but it is not working
<span lang="en-us">Sales As Of Analysis</span><br />
<asp:GridView ID="GridView1" runat="server" BackColor="White"
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3"
GridLines="Vertical">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:GridView>
<asp:BoundColumn DataField="PCTPAX1"
HeaderText="PCTPAX1"
DataFormatString="{0:c}">
</div>
</form>
</body>
</html>
and nothing happend to my data
If it's just a matter of displaying only two decimals, this can be accomplished in the display code for the DataGrid:
<asp:BoundField DataField="PCTPAX1"
HeaderText="PCTPAX1"
DataFormatString="{0:c}">
Note the DataFormatString value of {0:c} which specifies that the formatting of the value in that field should be "currency." (You can also try with a capital C, I don't have a test handy for it right now.) There's a lot more you can do with format strings, more information here.
Or do you want the actual values to be rounded to currency values? You'll likely use Math.Round for that, though I don't have an example handy. There's information about that here.
Edit: Based on your comment(s), it sounds like you were attempting to change data types at the database level. This won't really impact the code. The value coming back from the database in the form of a double or decimal or some other numeric likely won't carry that precision back to the code. As far as the DataGrid is concerned, it's calling .ToString() on a double and showing the result. No database data type is involved. Using the DataFormatString property to pass a format string to the .ToString() method is how to change the display.
Edit again based on your question edit: Your HTML is broken. You have the BoundColumn outside of the grid, and the column tag itself isn't closed. Columns go inside the grid. See the grid layout here. Basically, you'd want something more like:
<asp:GridView ID="GridView1" runat="server" BackColor="White"
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3"
GridLines="Vertical">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:BoundField DataField="PCTPAX1"
HeaderText="PCTPAX1"
DataFormatString="{0:c}">
</asp:BoundField>
</Columns>
</asp:GridView>
Changing the type of a column which is already in your datatable doesn't work. or at least not that i know. if you just want to get a different formatting, look at the answers above.
I am having an un-predictable behavior of creating radio buttons in advancedDataGrid column using itemRenderer. Similar kind of problem has been reported at
Creating a column of RadioButtons in Adobe Flex. I tried to use the same procedure i.e. bind every radio button selectedValue and value attributes with the property specified in the property of the associated bean but still facing the problem.
The button change values! The selected
button becomes deselected, and
unselected ones become selected.
Here is the code of my advancedDataGrid:
<mx:AdvancedDataGrid id="adDataGrid_rptdata"
width="100%" height="100%"
dragEnabled="false" sortableColumns="false"
treeColumn="{action}"
liveScrolling="false"
displayItemsExpanded="true" >
<mx:dataProvider>
<mx:HierarchicalData source="{this.competenceCollection}" childrenField="competenceCriteria"/>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn headerText="" id="action" dataField="criteriaName" />
<mx:AdvancedDataGridColumn headerText="Periode 1" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%" verticalAlign="middle">
<mx:RadioButton name="period1" value="{data}" selected="{data.period1}" group="{data.radioBtnGrpArray[0]}" visible="{data.showRadioButton}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
<mx:AdvancedDataGridColumn headerText="Periode 2" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%" verticalAlign="middle">
<mx:RadioButton name="period2" value="{data}" selected="{data.period2}" group="{data.radioBtnGrpArray[1]}" visible="{data.showRadioButton}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
<mx:AdvancedDataGridColumn headerText="Periode 3" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%" verticalAlign="middle">
<mx:RadioButton name="period3" value="{data}" selected="{data.period3}" group="{data.radioBtnGrpArray[2]}" visible="{data.showRadioButton}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
</mx:columns>
</mx:AdvancedDataGrid>
Any work around is highly appreciated in this regard!
The selected button becomes deselected, and unselected ones become selected.
Is this problem occurring only for those radio buttons whose selected state was manually changed by the user? In that case it is because flex resets its selected state based on the value mentioned in the declaration when a RadioButton is reused. So even if you select/deselect a ratio button in the Periode 1 column, flex resets it to {data.period1} when you scroll away and come back. Making the column editable to save the modifications back to the data provider might work. Try changing the column declaration to:
<mx:AdvancedDataGridColumn headerText="Periode 1" dataField="" width="200"
editable="true" rendererIsEditor="true" editorDataField="selected">
EDIT: Try this - attempting to change the data provider when the radio button is selected. code written from memory and not tested - might contain bugs.
<mx:AdvancedDataGridColumn headerText="Periode 1" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%"
verticalAlign="middle">
<mx:RadioButton id="rb" name="period1" value="{data}"
selected="{data.period1}"
group="{data.radioBtnGrpArray[0]}" visible="{data.showRadioButton}"
change="outerDocument.handleRadio1(this);"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
//in a script tag outside the datagrid.
public function handleRadio1(renderer:IListItemRenderer):void
{
var index:Number = adDataGrid_rptdata.itemRendererToIndex(renderer);
this.competenceCollection[i].period1 = renderer.rb.selected;
}
I have a grid view control in my application.
Please see the below code.
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="CPUserID" DataSourceID="GetSelectDelegatesDataSource">
<Columns>
<asp:BoundField HeaderStyle-CssClass="gridview_header" HeaderStyle-ForeColor="White" Visible="false" DataField="EmailAddress" HeaderText="Email Address" SortExpression="EmailAddress">
<HeaderStyle CssClass="gridview_header" ForeColor="White"></HeaderStyle>
</asp:BoundField>
<asp:TemplateField HeaderText="Select">
<HeaderTemplate>
<input id="masterCheck" type="checkbox" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkSelect" />
</ItemTemplate>
<HeaderStyle CssClass="gridview_header" ForeColor="White"></HeaderStyle>
</asp:TemplateField>
</Columns>
</asp:GridView>
And I have a image button
<asp:ImageButton ID="ibtnSendInvites" Visible="false" runat="server" ImageUrl="~/images1/send_button.png" />
If you see above code you can find that there is check box functionality in my gridview. I have email address boundfield in my gridview. I want to send an email to the email addresses which are been checked in gridview.
Please provide the vb.net code for the same
Very quickly thrown together, you can get the jist.. I didn't test it or anything.
Dim emailList As New List(Of String)
For Each curRow As GridViewRow In GridView1.Rows
Dim chkSelect As CheckBox = CType(curRow.Cells(1).FindControl("chkSelect"), CheckBox)
If chkSelect.Checked Then
emailList.Add(curRow.Cells(0).Text)
End If
Next
' you now have a generic list of email addresses..
System.Web.Mail provide the functionality to send mail from .Net framework. Download the sample project Send Mail- codeproject and see how this is implemented.
Check this link on BulkEditGridView. It's just like a GridView, but you can edit (or perform actions on) multiple rows of a gridview with one click. I use it and love it.