w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Change the name of column in Gridview on runtime when sorting of gridview is enabled
I'm guessing you're trying to use AutoGenerateColumns? If this is the case why can't you change the column name in the datasource (using "AS" if the datasource is SQL)? Otherwise, your altering the cell text is short-circuiting the ASP.NET functionality which generates the sorting javascript postback. Alternatively you would do this if you don't use AutoGenerateColumns: myGrid.Columns[1].HeaderText = "test1";

Categories : C#

Convert rows in table to columns for displaying into Header columns for Gridview
Assuming you are working with MS SQL server you need to use the PIVOT keyword. Link for the same: PIVOT AND UNPIVOT

Categories : C#

GridView columns header text
Change your SQL to: SelectCommand = "SELECT count(city) As CityCount, city FROM users ..." Therefore renaming the header to CityCount using ALIAS For more flexibility, disable autogeneration of column from the Gridview and specify it manually: AutoGenerateColumns="False" <asp:GridView AutoGenerateColumns="False" ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="True" PageSize="20" CellPadding="4" ForeColor="#333333" GridLines="None"> <asp:BoundField DataField="CityCount" HeaderText="Number of Cities" /> </asp:GridView>

Categories : C#

Get Columns Name or Header Text of GridView Using JavaScript
GridView is rendered as HTML table on your page source, hence you can use Jquery to get the , view source and check if its associated with any class and then you can use it as selector, or regular $('table tr th') this post may help you How to get a table cell value using jquery?

Categories : Javascript

How to set EditIndex property of the GridView to "Selected Row" in the GridView
Code something like this On edit click Gridview will be editable , gvBind() is method for binding your gridview with datatable protected void gv_RowEditing(object sender, GridViewEditEventArgs e) { gv.EditIndex = e.NewEditIndex; gvBind(); } protected void gv_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { gv.EditIndex = -1; gvBind(); }

Categories : C#

retrieve values in selected row of gridview from wpf
private void YourGridName_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) { string fc = null; foreach (var item in e.AddedCells) { fc =((System.Data.DataRowView(item.Item)).Row.ItemArray[0].ToString(); } }

Categories : C#

How to get the Values of Selected Row from a Gridview in TextBox on another page
As per your comment below are some links which may help you in passing the data from iframe to page1. Set variable in parent window from iframe How can I pass attribute value from iframe to parent in Javascript? How pass data to parent window from iframe?

Categories : Asp Net

Gridview Hypelink values based on row value and column header identifier
You can use a HyperLinkField or TemplateField to add links to your gridview, as shown here: http://stackoverflow.com/a/8859655/849182

Categories : Asp Net

How to approach in showing values from row in columns in gridview devexpress
Check this link for exporting GridViews. To accomplish your task, I think you can just do something like : foreach (Table1Class table1Class in Table1ClassList) // Table1ClassList contains all the records from Table1 { foreach (Table2Class table2Class in Table2ClassList.Where(e => e.ProductID.Equals(table1Class.ProductId))) { // Retrieving Column : your FieldNames should be correctly set GridColumn columnFromGrid = FinalGrid.Columns.Where(col => col.FieldName.Equals(table2Class.Column)).First(); // TODO : Populating Column } } I think this should do the trick !

Categories : Asp Net

Improve page rendering time having gridview, child gridview and grand child gridview on it
You are creating way too many grids. A grid is an expensive component. You could alter your user interface to allow users to select an Item and bind the inner grid only on selection. This ensures that rather than one grid per row or parent grid, you will have only one child grid displayed at a time.

Categories : C#

How to show item in dropdownlist as being selected when we have corresponding datatextfield from gridview selected row
Selected value does not work in this way. Try this: ddEquipmentName.SelectedIndex = ddEquipmentName.Items.IndexOf(ddEquipmentName.Items.FindByText(selectRow.Cells[2].Text));

Categories : C#

Set Fixed Row Height in GridView
I would look into the ImageView which I assume you would be using in your adapter to show the images. You should set android:layout_width and android:layout_height to 100dp and make sure that android:scaleType is set to centerCrop.

Categories : Android

asp.net gridview sorting and paging
The problem is you are calling getallemployees() on GridView1_PageIndexChanging function which ofcourse is returning unsorted data for next page. In order to resolve this issue, you need to use ViewState for your data to be persistant. Following solution will greatly help you out in sorting your grid using ViewState http://www.stackoverflow.com/questions/702600/sorting-and-paging-with-gridview-asp-net?rq=1

Categories : Asp Net

Sorting is not working on gridview
Unfortunately this is not going to work this way. DataSource property is not null only during data binding. In all other stages of page life-cycle (namely during events handling) it is null, unless you explicitly initialize it. In your case however solution is simple enough - just rebind the grid the way you have binded it before, just taking into account sorting info. First modify the bindGrid method to take sorting into account. private void bindGrid(string sort) { try { if (int.Parse(lblAccountNo.Text.ToString()) > 0) _clientTransection.AccountNo = Convert.ToInt32(lblAccountNo.Text.ToString()); Collection<ClientTransInvoiceRows> _clientList = _clientTransection.Execute(); if (string.IsNullOrEmpty(sort)) { // app

Categories : C#

VB Gridview Populating and Sorting
Well your first issue is that you do not have an onsorting attribute of your GridView defined, like this: onsorting="gvUserSearch_Sorting" This represents an event handler for whenever a sort operation is needed, such as the user clicking on the header of a column to sort it. I recommend that you change your DataSource type to DataTable, because the DataTable data structure lends itself to having a view built against it, which you will see later is how we can easily apply the sort direction and the sort expression for the column. Here is a utility function that can return a DataTable to be used by your DataSource property: Private Function GetGridViewDataSource() As DataTable Dim dtGrid As New DataTable() Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("Co

Categories : Vb.Net

Gridview Sorting event unhandled
you need to set the OnSorting="" property to some function name, and then handle the sorting in said function. something along these lines Protected Sub TaskGridView_Sorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs) 'Retrieve the table from the session object. Dim dt = TryCast(Session("table"), DataTable) If dt IsNot Nothing Then 'Sorting the data. dt.DefaultView.Sort = e.SortExpression & " " & GetSortingDirection(e.SortExpression) TaskGridView.DataSource = Session("TaskTable") TaskGridView.DataBind() End If End Sub Private Function GetSortingDirection(ByVal column As String) As String ' By default, set the sort direction to ascending. Dim sortDirection = "ASC" ' Retrieve the last column that was sorted.

Categories : Asp Net

How do I keep sorting order while paging in gridView?
You don't need to bind on each page load. if (_selectCmd != string.Empty) if(!IsPostBack) BindData(); Also, be carefull what you put in the ViewState, it's not good practice to put the sql query.

Categories : C#

Issue in Sorting date in gridview
var temp = table.AsEnumerable() .OrderBy(x => x.Field<string>("LossDate") !=null) .ThenByDescending(p => !DateTime.TryParse(p.Field<string>("LossDate"), out dt)) .ThenBy(x => x.Field<string>("LossDate")); var result =temp.AsDataView().ToTable(); and set above as DataSource of girdview Sample : DataTable table = new DataTable(); table.Columns.Add("LossDate", typeof(string)); table.Rows.Add(new DateTime(2004, 05, 27)); table.Rows.Add(DBNull.Value); table.Rows.Add("A90317"); table.Rows.Add(new DateTime(2009, 06, 27)); table.Rows.Add("A90118"); table.Rows.Add(DBNull.Value); table.Rows.Add("A00921"); table.Rows.Add(DBNull.Value); table.Rows.Add(new DateTime(2005, 06, 27)); DateTime dt; var temp = table.AsEnumerable() .OrderBy(x => x.Field<string&g

Categories : C#

Gridview -sorting event does not function
The SortDirection property on the GridView is changed only when the GridView is bound to a DataSource control using the DataSourceID property. Otherwise, sort direction needs to be managed manually. In this case when we provide Data to gridView using its DataSource property , e.SortDirection will always return Ascending. And therefore only your IF statement will always get executed. Second Point:: You need to optimize actually is just make sure you define a function to return the Data only. e.g say LoadGrid() only returns the DataTable. This way you don't need to define overloads of your LoadGrid() method. Morover, with a proper way of implementation, overloading is really not needed at all. Third point:: is that you aren't applying sorting at all, but just loading the GridView.When y

Categories : C#

Databind to gridview from backend c#, but show the fields only which is mentioned in BoundField of gridview
Set Gridview property AutoGenerateColumns="false" <asp:GridView ID="custdet" AutoGenerateColumns="false" runat="server"> <Columns> <asp:BoundField DataField="CustAccNo" HeaderText ="AccNo" /> <asp:BoundField DataField="Name" HeaderText="Customer Name" /> </Columns> </asp:GridView>

Categories : C#

Android - GridView onItemClick callback not being called When GridView is inside ViewPager
if the goal is simply to get the notification, use OnClickListener instead of OnItemClickListener. Set the listener via setOnClickListener in getView when convertView is null. Otherwise, if you need the extra information that you would get in onItemClick, you can specialize ImageView to set and retrieve the convenience members that you define in the specialized class.

Categories : Android

Get the value from editItem template field of gridview on update button click of gridview
I don't know if this will help you but do you mean something like this? http://www.martenc.com/2010/12/01/customvalidator-validating-both-empty-text-and-email-address/

Categories : Javascript

Nested gridview checkboxes are not toggling when master gridview checkbox is toggled
When you run your first CheckBoxAll_OnCheckedChanged you will be running through each checkbox and changing its Checked to True or False dependent on what the CheckBoxAll has been ticked as. This will not cause a postback on the checkbox per one being run. Instead, while looping through the nested gridview you can call the CheckBoxAdd_OnCheckedChanged sub by just passing the object and same eventargs over to it. For example: Sub CheckBoxAll_OnCheckedChanged(sender as object, e as eventargs) 'Loop through gridview here 'When finding the control CheckBoxAdd just call For each gvRow as GridviewRow in gvStudents.Rows dim CheckBoxAdd as Checkbox = gvRow.FindControl("CheckBoxAdd") CheckBoxAdd.Checked = True 'Or false dependent on CheckBoxAll CheckBoxAl

Categories : Asp Net

Fix Header Row of ASP.NET GridView
Your best bet would be to create two GridViews. One purely for the header. Second, for the body wrapped in a scrollable div just below the first one. Position the second gridview with a negative top margin to hide its header. This way you will use the header of the first girdview and scroll the second one. Alternatively, you can use a plugin like this one: http://www.fixedheadertable.com This plugin also uses the same logic as I described above.

Categories : Javascript

How to call Parent Gridview's item Id by Nested GridView's Content
Unfortunately, you can't do that. WebGrid will only bind to a single model and because the columns aren't strongly-typed you can't reference a parent class. The solution is to create a ViewModel that contains all of the data you want to represent in your WebGrid and then bind your WebGrid to that ViewModel.

Categories : Asp Net Mvc

How to disable sorting JQuery DataTable with asp.net Gridview
That's an interesting problem. The datatables forum has a discussion very closely related to the issue you are encountering. http://datatables.net/forums/discussion/11967/aocolumns-when-number-of-columns-vary/p1 Allan Jardine, creator of datatables, is part of the discussion, and his first reply recommended using aoColumnDefs and showed how you could do aTargets: [ '_all' ] to take care of the issue of variable number of columns. So based on a quick scan of the discussion on the datatables forum, here's a fiddle that might get you close to what you are looking for: http://jsfiddle.net/nLYLv/ $('#ctl00_ContentPlaceHolder1_GridView1').dataTable({ "bJQueryUI": true, "sPaginationType": "full_numbers", "aoColumnDefs": [ {"aTargets": [ 1 ], "bSortable":

Categories : Jquery

image is not displaying in templatefield from gridview sorting
It may be because you have not registered any trigger of gridview events. Try by adding a postback trigger for gridview. as: <asp:PostBackTrigger ControlID="grdBOMList" />

Categories : Asp Net

Asp.net Gridview with JQuery DataTable - Gridview events not fire
You can inline edit/update/save/delete your DataTable following this example or using the editor

Categories : Jquery

GridView RowDataBound event makes my GridView slow
You may need to consider jQuery Dialog instead of Asp.Net ajax popup extender. http://jqueryui.com/dialog/. Also, do you really need gridview, You can try ListView control instead of GridView.

Categories : Vb.Net

Add Checkbox to header of gridview
Not sure, but I think the HeaderText property in TemplateField might be causing problems with the HeaderTemplate. Looking at a code sample on MSDN, they don't use HeaderText when using the HeaderTemplate. Try something like this (not tested): <asp:TemplateField> <HeaderTemplate> <asp:CheckBox ID="ChkCity" Text="Physics" runat="server" /> </HeaderTemplate> <ItemTemplate> .... </ItemTemplate> </asp:TemplateField>

Categories : C#

How to add Header and Subheader in Gridview
hi you can do it like this <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="grvMergeHeader" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="5px" CellPadding="3" ForeColor="Black" GridLines="None" BorderStyle="None" CellSpacing="2"

Categories : Asp Net

How to add header row dynamically in gridview
You can do that using nested Gridview if you want to. And example can be found here Personally I would just use ListView or Repeater to do that.

Categories : C#

Wrong linkbutton command argument after sorting gridview
Here was the issue: When the LinkButton is clicked, the first thing that happens is the page reloads. However, Response.Redirect(Request.RawUrl) doesn’t preserve the ViewState, so the sort order is lost. Therefore, the GridView is repopulated with unsorted data. Then, the LinkButton onClick event function is called. The Object passed in is the LinkButton from the correct row number, but since the sort order of the table had changed (back to its unsorted state), the LinkButton in that row was no longer the LinkButton the user had clicked. Therefore, the command argument was wrong. To fix the issue: I changed all the ViewState[string] to Session[string] (so that the sort direction is preserved when the page reloads), and added the following code in the Page_Load function, before the G

Categories : Asp Net

Different text-style in Gridview Header
You could change the style on the header template like so: <HeaderStyle Font-Italic=true /> insert this tag just above your columns. EDIT: If I understand correctly you want to change the header styles of only one column to italic. An easy way to do this is to go to the design view, click the smart tag on the gridview and choose "edit Columns". Choose the column you'd like to change and choose HeaderStyle > Font > Italic > True. What you get is something like this: (You do not need to change your column to a template field> <asp:BoundField HeaderText="Bil. No." > <HeaderStyle Font-Italic="true" /> </asp:BoundField>

Categories : Asp Net

fixing gridview header while scrolling
I think this code can help you : http://www.codeproject.com/Articles/59160/Extended-GridView-with-Fixed-Header-and-Pager

Categories : C#

Windows store app, How to get the header value of gridview?
2 options : The MVVM way would be to use an ICommand instead of the event and pass the value as the command parameter. <Button x:Name="HeaderBtn" Command="{Binding HeaderCommand}" CommandParameter="{Binding Title}"> In the event Handler, you should be able to retrieve the data context of the button, and the value of title private void HeaderButton_Click(object sender, RoutedEventArgs e) { var button = (Button)sender; var dataContext = (HeaderClass)button.DataContext; var title = dataContext.Title; //here is your value }

Categories : C#

How do I set css classes for a gridview row and header by code?
I think you should be setting CssClass in the HeaderStyle property: lastCreatedOpportunitiesGrid.HeaderStyle.CssClass = Constants.CssClasses.HeaderRow; The HeaderRow property gives you the GridView's header after the databinding. Check http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.headerrow.aspx: "The HeaderRow property is available only after the GridView control creates the header row in the RowCreated event."

Categories : C#

how can i get a gridview column number from the header row value
Try this For Hiding Column based on Role protected void Page_Load(object sender, EventArgs e) { GridView1.Columns[3].Visible = false; } And for formatting protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (Session["Role"] == "admin") btnVal.Enabled = false; } } Find Column Index by Column Text private int GetColumnIndexByName(GridView grid, string name) { foreach (DataControlField col in grid.Columns) { if (col.HeaderText.ToLower().Trim() == name.ToLower().Trim()) { return grid.Columns.IndexOf(col); } } return -1; }

Categories : Asp Net

Sorting a GridView Bound to a Dataset, DataTable null on cast?
its hard to find from the code snippet why it is NULL, as per my knowledge but i can give u idea, at the time you bind your data table gridview, put the data table in view state or in session better to put in viewstate, and then retrieve data table at the time of sorting

Categories : C#

Getting row of selected DropDownList in GridView cells
You can find the grid view row by finding the grandparent (.Parent.Parent) of your drop down list, because the drop down list is within a cell of the row, which is a part of the row itself, so you need to go two levels up, like this: protected void chooseThemeTypeDropDown_OnSelectedIndexChanged(object sender, EventArgs e) { DropDownList chooseThemeTypeDropDown = sender as DropDownList; if (chooseThemeTypeDropDown != null) { System.Diagnostics.Debug.WriteLine(chooseThemeTypeDropDown.SelectedItem.Value.ToString()); GridViewRow row = (GridViewRow)chooseThemeTypeDropDown.Parent.Parent; } }

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.