|
You only need to handle the sorting event if there is some special case for sorting. The default mechanism should be sufficient for sorting on the column header.
only two letters away from being an asset
|
|
|
|
|
try with this code:
protected override void OnSorting(GridViewSortEventArgs e)
{
if (AllowMultiColumnSorting)
e.SortExpression = GetSortExpression(e);
base.OnSorting(e);
}
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
You need to refresh the data source so that it's sorted accordingly.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Where is GetSortExpression(e); How is this helpful?
only two letters away from being an asset
|
|
|
|
|
You're getting an infinite loop because calling GridView1.Sort will fire the GridView1_Sorting event (I'm sure you figured that out aleady)
I think GridView will only sort automatically if you're using one of the new DataSource providers, like SqlDataSource, XmlDataSource, ObjectDataSource, etc. (I could be wrong about that, but so far that's been my experience).
You could try something like:
private void FillGrid( string sortExpression, SortDirection sortDir )
{
string sort = sortExpression + " " + (sortDir == SortDirection.Descending ? "desc" : "" );
DataTable dt = GetDataTableFromSomewhere();
DataView dv = new DataView(dt, "", sort, DataViewRowState.CurrentRows );
GridView1.DataSource = dv;
GridView1.DataBind();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
FillGrid(e.SortExpression, e.SortDirection);
}
Viewstate could become an issue doing it this way. I typically disable view state on grids though, but then you have to work around a bunch of other issues.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I add a asp Checkbox in the Datagrid ItemTemplate and HTML checkbox in Header Template.In the datagrid am loading the images and the path from the server folder.am loading all the images in the page load event.page load event as follows
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable("Photos");
dt.Columns.Add("Photos", Type.GetType("System.String"));
foreach (string Files in Directory.GetFiles(System.Web.HttpContext.Current.Server.MapPath("Photos"), "*.jpg"))
{
dt.Rows.Add(Files);
}
ds.Tables.Add(dt);
this.dgPhotos.DataSource = ds;
this.dgPhotos.DataBind();
}
}
All the images am getting in the Datagrid.but my problem is,i want to delete the checked images.the delete code as follows
foreach (DataGridItem item in dgPhotos.Items)
{
CheckBox chkBox = (CheckBox)item.FindControl("chkItem");
if (chkBox.Checked)
{
File.Delete(item.Cells[2].Text);
}
}
while clicking the Header template checkbox it will select all the Item template checkbox[Javascript function],all the sub checkbox are checking fine.but the problem is i will not get the checked state in the delete event,getting checkbox.checked=false.so i cannot delete the images.in the page load event if am not using !Postback and if i select one by one in the Itemtemplate checkbox i could delete,i will get checked=true but if select header check will not get.what is the problem.Is there any solution for this.
|
|
|
|
|
Have you solved this problem?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi All
I have a gridview with 2 bound columns and 3 TemplateField columns containing 3 checkboxes. Iam not being able to display the check boxes correctly although thrie values are correct in the database.
Any Ideas?
|
|
|
|
|
I recommend fixing your code so it works.
For a more detailed answer, try posting some code, and explaining what you mean by 'unable to display correctly'
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have solved a part of it by binding the check boxes and giving them values from database. But there still is a bug which is when binding a certain type with no data, the gridview is not appearing while i need it to appear with empty checkboxes.
Thanks in advance.
<br />
dim ds as new dataset<br />
ds = DBUsers.Pages_Select(DDLTypes.SelectedValue)<br />
Dim tblPages As DataTable = New DataTable<br />
tblPages = ds.Tables(2)<br />
DGPages.DataSource = tblPages<br />
DGPages.DataBind()
stored procedure:
select * from usersAccess ua left outer join UsersOptionsAccessPages uap on ua.UsersOptionsAccessPages_ID =uap.UsersOptionsAccessPages_ID where ua.usersOptionsAccessLevels_Id= @TypeId
|
|
|
|
|
I'd imagine you need to bind the grid so it calls a codebehind method that won't blow up if there's no data for the checked property
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello Everyone,
I want to display a message as the checkbox of the GridView is checked.
For it i've used the following piece of code i'm sending under.
plz suggest me some solutions/ways
foreach(GridViewRow dt in dgState.Rows)
{
if (((CheckBox)dt.FindControl("chkSelect")).Checked == true)
{
lblMsg.Text="Checked ME!!!!!!!!!!!";
lblMsg.ForeColor = Color.DarkBlue;
}
}
|
|
|
|
|
what error it shows?
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
He didn't mention anything about an error. If you haven't figured it out, having the most posted with the lowest score doesn't get you any prizes. Just go away.
only two letters away from being an asset
|
|
|
|
|
|
Guess he didn't like my response. I'm so hurt by the low votes
only two letters away from being an asset
|
|
|
|
|
There - I've 5 voted you better now.
|
|
|
|
|
Good timing, I was just securing the rope and getting ready to step off the chair.
only two letters away from being an asset
|
|
|
|
|
you are showing dominant side that's why
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
Mark Nischalke wrote: I'm so hurt by the low votes
I didn't vote you Mark.
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
|
how can we fomrat a text box value to "##,###.00" format using javascript??
thankx in advance??
All I ever wanted is what others have.... CrazySanker
|
|
|
|
|
If you mean how can you mask the textbox, you can't. There is no concept of a masked textbox in HTML. What you could do though is to write a piece of javascript that was fired in the onBlur event to modify the text. This[^] example adds commas, so it should be easy enough for you to add the capability to put the .00 at the end.
A quick word of warning though - not all cultures use , as thousand separators. Some cultures use the decimal point . as the thousand separator and the comma as the decimal separator.
|
|
|
|
|
Thankx
All I ever wanted is what others have.... CrazySanker
|
|
|
|