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

get radgrid index after set_enable false ajax

4 Answers 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chap
Top achievements
Rank 1
Chap asked on 18 Oct 2012, 11:15 AM
I used radgrid view for display some of my data and using that rad view. I need to do two things
1. delete some records - need ajax manager
2. stream to web browser - need to disable ajax manager.

here is my code snipts 

<script type="text/javascript">
            function requestStart(sender, args) {
                if (args.get_eventTarget().indexOf("GD") > 0)
                    args.set_enableAjax(false);
            }
</script>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="requestStart">

in the grid
<%--<telerik:GridButtonColumn ButtonType="LinkButton" Text="<img src='../App_Themes/default/images/genDoc.gif' border='0' title='Generate Document'/>" UniqueName="GD" CommandName="G"></telerik:GridButtonColumn>--%>


<telerik:GridTemplateColumn HeaderText="" UniqueName="Image">
<ItemTemplate>
<asp:ImageButton ID="GD" runat="server" ImageUrl="~/App_Themes/Default/images/genDoc.gif" CommandName="1" OnClick="ImageButton1_Click">
</
asp:ImageButton>         
</
ItemTemplate><br></telerik:GridTemplateColumn>

in the code behind

  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
          if (e.CommandName == "G")
            {
                genDoc(e.Item.ItemIndex);
            }
        }

        protected void ImageButton1_Click(object sender, EventArgs e)                   //method 2
        {
            genDoc(0);
        }

If I use the commented link button thing it will go to the method run method well but not give me download a file. 
If I use image button it works well and I can download a file, but I cant get particular index to my method(e.Item.ItemIndex
)...{in the genDoc() - document.Save("Sample.doc", FormatType.Doc, Response, HttpContentDisposition.Attachment); }

any way what I want to pass e.Item.ItemIndex value to my method genDoc(int index)...Please help me. thanks

4 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Oct 2012, 01:53 PM
Hello,

protected void ImageButton1_Click(object sender, EventArgs e)    
   {
       int index = ((sender as ImageButton).NamingContainer as GridDataItem).ItemIndex;
       // Access ItemIndex here
   }


Thanks,
Jayesh Goyani
0
Chap
Top achievements
Rank 1
answered on 19 Oct 2012, 04:01 AM
Thanks very much, this works well
0
Chap
Top achievements
Rank 1
answered on 22 Oct 2012, 08:27 AM
hello again,

I need another help, can you tell me how to get the value of that cell relating the index. I can take this in e.commandName block using this
GridDataItem item = e.Item as GridDataItem;
string tmpName = item["TemplateName"].Text;

what I want is get tmpName in that  ImageButton1_Click

is this a good way string tmpName = ((sender as ImageButton).NamingContainer as GridDataItem)["TemplateName"].Text;

Thanks you
0
Accepted
Shinu
Top achievements
Rank 2
answered on 22 Oct 2012, 09:00 AM
Hi Chap,

Try the following code snippet to achieve your scenario.

C#:
protected void ImageButton1_Click(object sender, EventArgs e)
{
    GridDataItem ditem = ((sender as ImageButton).NamingContainer as GridDataItem);
    string tmpName = ditem["TemplateName"].Text;
}

Hope this helps.

Regards,
Shinu.
Tags
Grid
Asked by
Chap
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Chap
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or