C# - How To Sort The Grid View Whose Column Is Listing Integers
Feb 17, 2011
I am sorting the grid using DataView's "Sort" property. I am passing sort expression and the order in which the grid is to be sorted(ASC or DESC). But the problem is, since the column on which I am sorting the grid is listing the intergers, the sorting is happening as if it is a string. But I need integer sorting rather string sorting on that column.
The grid displays below as ascending order(string sorting)
55
77
8
But I need the columns to be displayed like this(Integer sorting)
8
55
77
View 2 Replies
Similar Messages:
Aug 17, 2010
I have a GridView in ASP.Net 3.5. I added BoundFields as columns, set DataField and Header Text. Total I have 6 columns like that. Although I set "AllowSorting=True" in design view, when I run this page, all the columns didn't have hyper link that I can click on it and sort that particular column. I bind this column at code behind by using datatable.
gv.DataSource = dtDispatch
gv.DataBind()
View 1 Replies
Jul 21, 2010
I have a grid view with manual sorting. In some cells, the data are numeric and datetime. But due to some constrains, the data type on tables are varchar. The problem here is when I sorting those numeric data, it is treated as varchar.Eg: 1, 12, 13, 2, 23, 3, ...But I wanted the order to be: 1, 2, 3, 12, 13, 23, ...I have tried these method, but it doesnt works.
[Code]...
View 9 Replies
May 27, 2010
i have a grid view with some coulmns like Name,Phone no etc with Edit,Delete column in grid view. I click a row in grid view to Edit,it goes another page where i can edit all fields .Once i update i redirect the page to gridview. I want the grid view to remain in that particular page say 4 of the grid view
View 5 Replies
May 12, 2010
In gridview I am able to sort on 1 column as mentioned below, I want to add one more column in sorting, what is the best way to do this,
[Code]....
View 2 Replies
Jan 10, 2011
I have this code that once a column in gridview is clicked, it sort the record. Can someon explain to me what does
static Int32 cntsortSecurityID = 0; // declare var to hold 0 or 1 // what is this, I dont understand why. what is the meaning of zero or One in this case . Oh yeas, the code is working for me, but I need to understand the concept behind it.
if (e.CommandName == "sortSecurityID")
{
DataView dv = ((DataSet)(Session["data"])).Tables[0].DefaultView;
if (cntsortSecurityID == 0)
{
dv.Sort = "SecurityID asc";
cntsortSecurityID = 1;
}
else
{
dv.Sort = "SecurityID desc";
cntsortSecurityID = 0;
}
gvTrans.DataSource = dv;
gvTrans.DataBind();
}
View 3 Replies
Jan 4, 2010
wondering if someone can possibly help me out with a gridview. I have data coming into a grid and I know how to filter the data using one dropdown, I'm trying to get a little more advanced now. I'd like to filter using three dropdowns.
This is what I have so far: I don't know how to hook the downlists to the query?
<asp:DropDownList runat="server" id="DropDownList1" Width="90px">
<asp:ListItem Value="item_num">Item #</asp:ListItem>
<asp:ListItem Value="lot_num">Lot #</asp:ListItem>
<asp:ListItem Value="production_code">Production Code
</asp:ListItem>
<asp:ListItem Value="batchcode">Batch Code</asp:ListItem>
<asp:ListItem Value="inbound_no">Inbound #</asp:ListItem>
<asp:ListItem Value="recv_date">Received Date</asp:ListItem>
<asp:ListItem Value="location">Location</asp:ListItem>
<asp:ListItem Value="category">Category</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList runat="server" id="DropDownList2" Width="160px">
<asp:ListItem Value="=">is equal to</asp:ListItem>
<asp:ListItem Value="<=">is less than or equal to
</asp:ListItem>
<asp:ListItem Value=">=">is greater than or equal to
</asp:ListItem>
<asp:ListItem Value="<>">is not equal to</asp:ListItem>
<asp:ListItem Value="begins with">Begins With</asp:ListItem>
<asp:ListItem Value="Like">Ends With</asp:ListItem>
</asp:DropDownList>
<asp:TextBox runat="server" id="TextBox1" Width="150px">
</asp:TextBox>
<asp:Button runat="server" Text="Go" id="Button8" BackColor="Lime" />
<asp:Button runat="server" Text="Clear Filter" id="Button9" /><br />
<input name="Checkbox1" type="checkbox" /><label id="Label5">
Include Items containing "Zero on Hand" Quantity.<br />
Group by Fields: <input name="Checkbox2" type="checkbox" />
Item/Lot
<input name="Checkbox3" type="checkbox" /> Production Code
<input name="Checkbox4" type="checkbox" /> Batch Code</label><label id="Label4"></label><br />
<hr />
<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Font-Size="Small" BorderStyle="None" BackColor="White" GridLines="Vertical" BorderColor="#999999" BorderWidth="1px" CellPadding="3" Font-Underline="False"
AllowSorting="True" AllowPaging="True" PageSize="20">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:boundfield DataField="STATUS" HeaderText="Status" SortExpression="STATUS">
</asp:boundfield>
<asp:boundfield DataField="ITEM_NUM" HeaderText="Item #" SortExpression="ITEM_NUM">
</asp:boundfield>
<asp:boundfield DataField="LOT_NUM" HeaderText="Lot #" SortExpression="LOT_NUM">
</asp:boundfield>
<asp:boundfield DataField="LOT_EXT" HeaderText="Lot Ext" SortExpression="LOT_EXT">
</asp:boundfield>
<asp:boundfield DataField="RECV_DATE" HeaderText="Recv Dt" SortExpression="RECV_DATE">
</asp:boundfield>
<asp:boundfield DataField="PRODUCTION_CODE" HeaderText="Prod Code" SortExpression="PRODUCTION_CODE">
</asp:boundfield>
<asp:boundfield DataField="QTY_ONHAND" DataFormatString="{0:NO}" HeaderText="OnHand" SortExpression="QTY_ONHAND">
</asp:boundfield>
<asp:boundfield DataField="QTY_RESERV" HeaderText="Reserv" SortExpression="QTY_RESERV">
</asp:boundfield>
<asp:boundfield DataField="QTY_AVAIL" DataFormatString="{0:N}" HeaderText="Avail" SortExpression="QTY_AVAIL">
</asp:boundfield>
<asp:boundfield DataField="QTY_ADJUST" HeaderText="Adjust" SortExpression="QTY_ADJUST">
</asp:boundfield>
<asp:boundfield DataField="QTY_SHIP" HeaderText="Shipped" SortExpression="QTY_SHIP">
</asp:boundfield>
<asp:boundfield DataField="QTY_RECV" HeaderText="Recv" SortExpression="QTY_RECV">
</asp:boundfield>
<asp:boundfield DataField="PROD_DATE" HeaderText="Prod Date" SortExpression="PROD_DATE">
</asp:boundfield>
<asp:boundfield DataField="RELEASE_DATE" HeaderText="Release" SortExpression="RELEASE_DATE">
</asp:boundfield>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle HorizontalAlign="Center" BackColor="#999999" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" ForeColor="White" Font-Bold="True" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:GridView>
<asp:SqlDataSource runat="server" id="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:RemoteRooster %>" SelectCommand="SELECT * FROM [INVENTRY] WHERE OWNER = 'CompanyName' AND QTY_ONHAND > '0'">
</asp:SqlDataSource>
View 8 Replies
Sep 16, 2010
how to write grid view template (All option sort,) in code behind
View 1 Replies
Nov 17, 2010
If the grid column is clicked to sort i dont want to retireve data agian, i can get it from viewstate, but i dont know if that triggered the post back or if the ImageButton on the page triggered it
View 5 Replies
Jun 3, 2010
I have a simple dynamic gridview with following code -
GV = new GridView();
View 3 Replies
Sep 15, 2010
In grid view I want to sort the particular column. For that we have to access that column
How to do this??
View 3 Replies
Apr 20, 2010
I have gridview and want to show datalist in grid view view column on click of linkbutton show.
[Code]....
View 2 Replies
Feb 7, 2011
I have class Person, having two properties First Name and Last Name, if I set array of person as Data Source to GridView how can I show both First Name and Last Name in one column?/
View 2 Replies
Apr 14, 2010
I have a gridview which automatically adjusts with the dataset but i want to adjust he size a bit
how to set the column size to a fixed size
View 2 Replies
Aug 19, 2010
i have a grid view myGridView. I populate this gridview in the page load event as:
myClass newObj = new myClass();
myGridView.datasource = newObj.getItems();
myGridView.databind();
Now I wanted to hide some of the columns of the grid view. How I can do that?
View 5 Replies
Aug 20, 2010
i am resizing grid view column header in updatepanel using javascript,it is working properly but my grid view displaying large amount of data at that time,so i need to come top of page for resizing gridview column header,so can i resize Grid view column header using gridlines?
gridlines means we can resize column in gridview anywhere,but i don't know it is possible or not?
View 1 Replies
Apr 29, 2010
I want to hide a grid view column if that column is empty. How do I do this? I dont have much exp. with grids.
View 23 Replies
Mar 10, 2011
I am using asp.net grid view which has is populated dynamically that means it has auto generated columns at run time.
I just want to know db type of these columns whether a column is text , date or int type.
View 1 Replies
Jun 24, 2010
I got this code which bind a datatable to a grid view. After the binding, i wanted to add additional column to the right of the grid, how can I do that? My codes below failed to do it.
[Code]....
The Header value of "ID1" is shown, but the cells only shows a '-' instead of 'New Column' sign.
View 4 Replies
Nov 8, 2010
How can i create a hyperlink to Grid view column, when i click this column it should open Word documentnt.Each Column row values does have seperate information.
View 3 Replies
Apr 1, 2011
Display grid view with column names when row count is zero. I dont want to insert new row when row count is zero. How can I achieve this
View 2 Replies
Jul 23, 2010
I have a dynamically created grid view in the load even of my web page. I am setting its data source at run time like
gv.datasource = someObject.getItems();
gv.dataBind();
Now I wanted to hide, that is to make some of the columns visible false.
First how can I do that, Second should I write the code in the same page_load event or I should write the code some where else, cause when I add this line of code
gv.colums[0].visible=false;
an exception is produces "Argument out of range"
View 3 Replies
Dec 15, 2010
I have a grid view which is made up of bounded and template columns. I have a check box which i select to show all/ show non empty columns.
My issue is hidding the template columns. I have the following code:
[Code]....
My issue is with the piece of code
[Code]....
How do I find the ID of the label in grid view column for the template column?
View 2 Replies
Mar 1, 2010
I am in the process doing drag n drop for gridview by column cell. For example: there is 5 cell in a column, user are able to drag the first cell and drop it as 3rd cell.I have find through the internet but has find no resource on it.
View 1 Replies
Jan 4, 2011
i hav a dyanmically generated gridview with autogenerated columns = true.. i want to change the width of a column of a grid... i tried to do it in row databound event as...
e.Row.Cells[1].Width = Unit.Pixel(300);
but it doesnt work... and since d columns are genrated dynamically i cant set d width as grd.columns[0].width =...
View 3 Replies