RE: GataGrid Command Link Problem
- From: Alex Maghen <AlexMaghen@xxxxxxxxxxxxxxxx>
- Date: Tue, 13 Jun 2006 07:14:02 -0700
Walter -
I think you have this exactly right - Except that I'm working in ASP.NET
2.0. As to Source code, well, I guess I can give you a stripped down version
that's simpler than the real thing and maybe that'll still help you help me!
SAMPLE CODE:
(See comments that start with "//**" below...
protected void Page_Load(object sender, EventArgs e)
{
LoadIssuesDG(m_FilterName, m_SearchStr, m_SortBy);
}
protected void LoadIssuesDG(string FilterName, string SearchStr, string
SortBy)
{
string SQL = BuildQuery(FilterName, SearchStr, SortBy);
OleDbDataReader DR = DB.DoParamSQLGetDataReader(SQL);
if (DR != null)
{
IssuesDG.DataSource = DR;
IssuesDG.DataBind();
}
else
{
ListDescripLB.Text += "<br/>NO ISSUES RETURNED FOR THIS SEARCH.";
}
}
protected void IssuesDG_Sort(Object sender, DataGridSortCommandEventArgs
e)
{
string SortExpression = e.SortExpression.ToString();
LoadIssuesDG(m_FilterName, m_SearchStr, SortExpression);
}
protected void IssuesDG_Command(Object sender, DataGridCommandEventArgs e)
{
string ID = e.Item.Cells[0].Text;
switch (((LinkButton)e.CommandSource).CommandName)
{
case "Edit":
EditItem(ID); //** BEFORE SORT, WORKS FINE. AFTER SORT, ID
IS INCORRECT!
break;
case "View":
ViewItem(ID); //** BEFORE SORT, WORKS FINE. AFTER SORT, ID
IS INCORRECT!
break;
default:
// Do nothing.
break;
}
}
THANKS SO MUCH FOR YOUR HELP!
Alex
"Walter Wang [MSFT]" wrote:
Hi Alex,.
Thank you for your post.
Based on my understanding, the question is:
1) You are using DataGrid in ASP.NET 1.1 and it's bound to some data
source;
2) It's set to sortable and you're using the SortCommand to sort it based
on the clicked column's SortExpression, and rebind it after sort.
3) You have some ButtonColumn which are associated with the row index in
the CommandArgument
4) After sort, the ButtonColumn's associate row index is not correct
If I've misunderstood anything, please feel free to post here.
I think the most possible cause of this problem would be: when you rebind
the DataGrid after sorting, the ButtonColumn's associated row index might
not be updated.
If this is not the case or you need more help on this, would you mind
posting some code here so that we can work on it more closely? Thanks.
Regards,
Walter Wang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
- Follow-Ups:
- RE: GataGrid Command Link Problem
- From: Walter Wang [MSFT]
- RE: GataGrid Command Link Problem
- References:
- RE: GataGrid Command Link Problem
- From: Walter Wang [MSFT]
- RE: GataGrid Command Link Problem
- Prev by Date: Re: Don't have Release Mode
- Next by Date: Re: DayPilot 2.0 - open-source event calendar (scheduling) control for ASP.NET
- Previous by thread: RE: GataGrid Command Link Problem
- Next by thread: RE: GataGrid Command Link Problem
- Index(es):
Relevant Pages
|