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

How to open edit form WebUserControl using link button outside the grid

4 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ELBU
Top achievements
Rank 1
ELBU asked on 19 Nov 2008, 02:14 PM
Hello,

I'll appreciate you help, since I'm trying to perform this action for a couple of hours without success.

I have a button , let's call it "ADD NEW ROW IN GRID"
Additionally , I have 3 link buttons placed on top of grid : add new record  , update record,  delete record

for some reason I need my WebUserControl form to be opened not from the link of the grid itself, but using
the button  "ADD NEW ROW IN GRID"

I tried to make ON CLICK event and from it I call another event  

 

protected void btnAddNewRow_OnClick(object sender, ImageClickEventArgs e)

 

{

 

       if (Page.IsValid)

 

 

            this.btnAdd_OnClick(sender, e);

 

}
I get an error in this case.....
What am I missing ?

When I press the link on the grid itself , it works just fine , so what is the difference ?

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Nov 2008, 11:12 AM
Hello ELBU,

From what I understand, i suppose you want to open an insert form in the grid on clicking a button outside the grid. If this is the case then try out the following to achieve the same :
aspx:
<asp:Button ID="btnAddNewRow" runat="server" Text="AddNewRowButton" OnClick="btnAddNewRow_Click" />    

cs:
 protected void btnAddNewRow_Click(object sender, EventArgs e) 
    { 
        RadGrid1.MasterTableView.IsItemInserted = true
        RadGrid1.Rebind(); 
    } 

Thanks
Princy.
0
ELBU
Top achievements
Rank 1
answered on 20 Nov 2008, 12:15 PM
Thanks a lot !!!
0
Bibek
Top achievements
Rank 1
answered on 06 Jan 2009, 03:00 PM
The code is helpful for me as well. But how can we edit the particular row in the same way. What I want is: user will select the row and click the button outside the gridview to edit that row.

Thanks in advance
0
Shinu
Top achievements
Rank 2
answered on 07 Jan 2009, 03:48 AM
Hi Bibek,

Try out the following code snippet to achieve the desired scenario.

CS:
  protected void LinkButton1_Click(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.SelectedItems) 
        { 
            item.Edit = true
        } 
        RadGrid1.Rebind(); 
    } 


Thanks
Shinu.
Tags
Grid
Asked by
ELBU
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
ELBU
Top achievements
Rank 1
Bibek
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or