R
Ruy Castelli
Hello,
I'm trying to get the details out of a datagrid component and it works fine
when I'm accessing the first page of the datagrid, but when I try to click
on the details hyperlink for an item that is not on the first page, the
web-page displays the first page of the datagrid again and show the details
of the field on the same location, but on the first page.
For instance, if I have the first page with the following data:
Header:
DATE NAME MSG HYPERLINK
data
01/05 A B Details
02/05 C D Details
And on the second page I've got something like this:
Header:
DATE NAME MSG HYPERLINK
data
01/05 E F Details
02/05 G H Details
If I click on the details for E and F (first line of the second page), the
page returns to the first one and the details return as NAME=A and MSG=B.
Here is my Page_Load event, I tried to use the FillData only when the server
starts, but then when I have a postback the datagrid is empty.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
try
{
oleDbConnection1.Open();
oleDbDataAdapter1.SelectCommand.CommandText =
"SELECT hour, name, msg FROM [msg log]";
oleDbDataAdapter1.Fill(dataset11);
DataGrid1.DataBind();
}
catch (System.Data.OleDb.OleDbException exception)
{
Error.Visible = true;
Error.Text = "Server error: " + exception.ToString();
}
finally
{
oleDbConnection1.Close();
}
}
Here is my PageIndexChanged event:
private void DataGrid1_PageIndexChanged(
object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataBind();
}
And here is my ItemCommand event:
private void DataGrid1_ItemCommand(
object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName=="det")
{
Label5.Text = "Correct Command";
Label3.Text = e.Item.Cells[0].Text;
Label4.Text = e.Item.Cells[1].Text;
Label6.Text = e.Item.Cells[2].Text;
}
}
Please, if you have any idea, let me know.
Thanks.
Ruy.
I'm trying to get the details out of a datagrid component and it works fine
when I'm accessing the first page of the datagrid, but when I try to click
on the details hyperlink for an item that is not on the first page, the
web-page displays the first page of the datagrid again and show the details
of the field on the same location, but on the first page.
For instance, if I have the first page with the following data:
Header:
DATE NAME MSG HYPERLINK
data
01/05 A B Details
02/05 C D Details
And on the second page I've got something like this:
Header:
DATE NAME MSG HYPERLINK
data
01/05 E F Details
02/05 G H Details
If I click on the details for E and F (first line of the second page), the
page returns to the first one and the details return as NAME=A and MSG=B.
Here is my Page_Load event, I tried to use the FillData only when the server
starts, but then when I have a postback the datagrid is empty.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
try
{
oleDbConnection1.Open();
oleDbDataAdapter1.SelectCommand.CommandText =
"SELECT hour, name, msg FROM [msg log]";
oleDbDataAdapter1.Fill(dataset11);
DataGrid1.DataBind();
}
catch (System.Data.OleDb.OleDbException exception)
{
Error.Visible = true;
Error.Text = "Server error: " + exception.ToString();
}
finally
{
oleDbConnection1.Close();
}
}
Here is my PageIndexChanged event:
private void DataGrid1_PageIndexChanged(
object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataBind();
}
And here is my ItemCommand event:
private void DataGrid1_ItemCommand(
object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName=="det")
{
Label5.Text = "Correct Command";
Label3.Text = e.Item.Cells[0].Text;
Label4.Text = e.Item.Cells[1].Text;
Label6.Text = e.Item.Cells[2].Text;
}
}
Please, if you have any idea, let me know.
Thanks.
Ruy.