views:

62

answers:

1

I am facing a slight problem with both events clashing with one another.

I have a column displaying a link button, so that when user clicks on it, it would direct them to another page displaying the data in the specific row of the datagrid.

Below the datagrid, I have number pages, which just so happens to be a link button as well and when user clicks on page 2, it would display the page 2 data of the datagrid.

The problem now is that, when I want to click to page 2, it would redirect to the next page, which is the event of my ItemCommand.

Are there any ways of which I could make the datagrid differentiate, which is the correct link button to read,

So that both of them do not clash with one another??

protected void RPYGrid_ItemSelect(object sender, DataGridCommandEventArgs e) { DataSet dsGenRequestPayment = new DataSet(); dsGenRequestPayment = GenerateRequestPayment(); DataTable dtRequest = new DataTable(); dtRequest = dsGenRequestPayment.Tables[0];

    if (((LinkButton)e.CommandSource).CommandName == "ItemSelect")
    {
        try
        {
            int iIndex = e.Item.DataSetIndex;
            string sId = RPYGrid.DataKeys[iIndex].ToString();

            foreach (DataRow drRequest in dtRequest.Rows)
            {
                string sRequestID = drRequest["RequestNo"].ToString();

                if (sId == sRequestID)
                {
                    sRequestNo = drRequest["RequestNo"].ToString();
                    sAmount = drRequest["RequestAmt"].ToString();
                    sAttachment = drRequest["FilePath"].ToString();
                    sReqCompanyID = drRequest["RequestCompanyID"].ToString();
                    sPayCompanyID = drRequest["PayerCompanyID"].ToString();
                    sReqCoName = drRequest["RequestCoName"].ToString();
                    sPayCoName = drRequest["PayerCoName"].ToString();
                    sRequestDate = drRequest["RequestDt"].ToString();
                }
            }
            dtRequest.Clear();
            dsGenRequestPayment.Clear();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message.ToString());
        }

    }
}

protected void RPYGrid_PageIndexChanged(object sender, DataGridPageChangedEventArgs e)
{
    RPYGrid.CurrentPageIndex = e.NewPageIndex;
    GenerateRequestData();
}
A: 

Does that still happen to you by having different command names in your linkbuttons? I think I didnt understand very well your question

is this what you want to do ?

 Select Case (CType(e.CommandSource, LinkButton)).CommandName
            Case "paging"
               'dopaging
            case "redirect"
               'doredirect

            Case Else
  End Select
Pablo
Hey Pablo, thanks for the time to answer my problem... I have got a linkbutton, which has a command called ItemSelect and when user clicks on this linkbutton, it would capture the details in the specific row in the datagrid and store those details as sessions. However, below the datagrid, I have want to allow the user to click on the NumericPages, so it would switch to the next page of the datagrid.But at the moment, the NumericPages firing the PageIndexChanged would fire my ItemSelect command instead of its own command. I been running tests on it but it still won't work...
Hubert