473,378 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Postback does maintain datagrid sort direction image ?

Hi, All:
I dynamic add an arrow up/down image in OnItemDataBound event for my
datagrid, it works fine. But I have another textbox which trigger
postback and doing something, after this event get executed, I lost the

image but the datagrid maintain the same sort order. Should the
datagrid remain what it looks like (with the riget arrow up/down image)

before the postback caused by the textbox?

I tried to get the datagrid header in the text postback event
(OnChanged), but I do not know how to get the datagrid header. I do not

want to rebind the datagrid in the textbox OnChanged event.
Or should I use other method to show the sort direction image?
private void dgrid_OnItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//Sorting Image
if(e.Item.ItemType == ListItemType.Header)
{
foreach(TableCell tc in e.Item.Cells)
{
if(tc.Controls.Count > 0)
{
try
{
LinkButton lkbSortCol =
(System.Web.UI.WebControls.LinkButton)tc.Controls[0];

if(lkbSortCol.CommandArgument.ToString().Equals(dg rid.Attributes["SortExpre*ssion"]))

{

System.Web.UI.WebControls.Image imgSort = new
System.Web.UI.WebControls.Image();

if(dgrid.Attributes["SortDirection"].Equals("DESC"))
{

imgSort.ImageUrl = Server.MapPath("Images/sort_desc.gif");
}
else
{

imgSort.ImageUrl = Server.MapPath("Images/sort_asc.gif");
}
tc.Controls.AddAt(1,
imgSort);
}
}
catch(Exception ex)
{
Trace.Write(ex.Message);
}
}//end if tc.controls.count > 0
}//end for
} //end item type
Thanks a lot
-Rockdale

Jun 8 '06 #1
0 1387

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
10
by: Krista Lemieux | last post by:
I'm new to ASP.NET and I'm not use to the way things are handled with this technology. I've been told that when I have a control, I should only bind the data to it once, and not on each post back...
1
by: Lisa | last post by:
I have a web app that gets a recordset from the database and fills a grid. You can drilldown from this table to a detail table. Because the tables sometimes get huge, and because I have to go...
1
by: darin_dimitrov | last post by:
I have an application which consists of 2 web forms. On the first page I have a datagrid with paging and sorting turned on. I also have a textbox which allows me to filter the data in the grid and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.