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

RadGrid1_ItemCreated

4 Answers 232 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 13 Jun 2011, 11:08 AM
In RadGrid1_ItemCreated How to get commandname value or delete button value

Very Urgent


Thanks,
Mohamed.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Jun 2011, 11:58 AM
Hello Mohammed,

I suppose you want to access GridButtonColumn and check for its CommandName in ItemCreated. If that is the requirement, here is the code that I tried. Hope this helps.

aspx:
<telerik:GridButtonColumn CommandName="Delete" UniqueName="delete"></telerik:GridButtonColumn>

C#:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
 if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
       LinkButton btn = (LinkButton)item["delete"].Controls[0];
      if (btn.CommandName == "Delete")
      {
             //your code here
      }
  }
}

Thanks,
Princy.
0
mohamed
Top achievements
Rank 1
answered on 13 Jun 2011, 12:04 PM
Thanks replay princy

How to fine boundcolumn in that commandname .

What i Click that id only come but grid bound last id is come
please replay soon


protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                TableCell cell = item["DeleteColumn"];
                ImageButton btn = (ImageButton)cell.Controls[0]; //NOT RECOMMENDED                               
 
                if (btn.CommandName == "Delete")
                {
                                                               GridDataItem item1 = (GridDataItem)e.Item;
                                                               TableCell txtb = item1["AssetID"];                       
                                                               TextBox txt = (TextBox)txtb.Controls[0];
                }
            }
        }
bold one error get like that Specified argument was out of the range of valid values.Parameter name: index

Thanks,
Mohamed.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 13 Jun 2011, 07:27 PM
Hi,


if (btn.CommandName == "Delete")
                {
                 GridDataItem item1 = (GridDataItem)e.Item;
                  String strTemp =  ((TextBox)item1["BoundColumnUniqueName"].Controls[0]).Text;
                 //if above line gives error related to index then use "Controls[1]"
                }

Thanks,
Jayesh Goyani
0
mohamed
Top achievements
Rank 1
answered on 14 Jun 2011, 04:22 AM
hi Jayesh Goyani

now also same problem come


Thanks,
Mohamed.
Tags
Grid
Asked by
mohamed
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
mohamed
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or