This is a migrated thread and some comments may be shown as answers.

Change link target for "Add new record" link

5 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 09 Oct 2012, 11:47 AM
Hello,

Id like to have the built in "Add new record" at the top of my grid, but instead of opening an input form in the grid id like to link to a form of my own instead.

How can i do this?

Thanks

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Oct 2012, 11:55 AM
Hi,

One suggestion is that you can use FormTemplate to open custom for. Here is the demo which implements the same.
aspx:
<EditFormSettings EditFormType="Template">
    <FormTemplate>
          . . .
   </FormTemplate>
</EditFormSettings>


Thanks,
Shinu.
0
Robert
Top achievements
Rank 1
answered on 09 Oct 2012, 12:15 PM
Thank you, but what im looking for is not a form inside the grid. I got an insertform on a different page id like to link to. So can i simple cause the "Add new record" click to send me to this page and not open any form, custom or otherwise, in the grid.

I could just add a link outside the grid to this page, but i like how it looks.

Also id like to change the display text for Add new record, if you know how i can do this, id really appreciate it.

Thanks
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 09 Oct 2012, 12:25 PM
Hello,

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
   {
       if (e.CommandName == RadGrid.InitInsertCommandName)
       {
           // Your logic comes here
           e.Canceled = true;
       }
   }

<MasterTableView ..............
 
           <CommandItemSettings AddNewRecordText="Your New text comes here" />


Thanks,
Jayesh Goyani
0
Shinu
Top achievements
Rank 2
answered on 10 Oct 2012, 05:47 AM
Hi,

One suggestion is that you can access the buttons and set the PostBackUrl property.
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridCommandItem)
  {
    GridCommandItem item = (GridCommandItem)e.Item;
    Button btn = (Button)item.FindControl("AddNewRecordButton");
    LinkButton Addbtn = (LinkButton)item.FindControl("InitInsertButton");
    Addbtn.PostBackUrl = "Page.aspx";
    btn.PostBackUrl = "Page.aspx";
  }
}

Thanks,
Shinu.
0
Robert
Top achievements
Rank 1
answered on 10 Oct 2012, 08:32 AM
Exactly what i was looking for. Thank you very much
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Robert
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or