open radwindow with gridview selectedindexchanged

5 posts, 1 answers
  1. Somy
    Somy avatar
    6 posts
    Member since:
    May 2013

    Posted 02 May 2013 Link to this post

    I have a gridview with a command field. at selected index change I set the gridviews row content to some textboxes.
    I want to open a radwindow with selected indexchanged of gridview but I couldn't do that.
    my code for radwindow at aspx file is:
    <telerik:RadWindow ID="RadWindow1" runat="server" Width="800px" Height="600px" Modal="true"  OpenerElementID="showDialog" OnClientClose="clientClose" OnClientShow="clientShow" ReloadOnShow="true">
           
          <ContentTemplate>
          <asp:TextBox ID="TxtTitle" runat="server"></asp:TextBox>
          <br />
          <asp:TextBox ID="TxtDetail" runat="server"></asp:TextBox>
          <br />
          <asp:TextBox ID="TxtDate" runat="server"></asp:TextBox>
          <br />
           
     
          <telerik:RadEditor ID="RadEditor1" runat="server"  ImageManager-ViewPaths="~/Images"
      ImageManager-UploadPaths="~/Images"
      ImageManager-DeletePaths="~/Images">
          </telerik:RadEditor>
     
          <br />
     
     
          <asp:FileUpload ID="FileUpload1" runat="server" />
          <br />
          <asp:CheckBox ID="ChkActive" runat="server" />
          <br />
          <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="save" />
          <br />
     
          </ContentTemplate>
          </telerik:RadWindow>
    and the code behind for selectedindexchanged:
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
       {
            
           int index = GridView1.SelectedIndex;
           TextBox txttitle = (TextBox)(GridView1.Rows[index].FindControl("TxtTitle"));
           TxtTitle.Text = txttitle.Text;
     
           TextBox tx = (TextBox)(GridView1.Rows[index].FindControl("TxtDetail"));
           TxtDetail.Text = tx.Text;
           TextBox descttext = (TextBox)(GridView1.Rows[index].FindControl("TxtDesc"));
           RadEditor1.Content = descttext.Text;
           CheckBox chk = ((CheckBox)GridView1.Rows[index].FindControl("Chactive"));
           ChkActive.Checked = chk.Checked;
     
       }
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 May 2013 Link to this post

    Hi,

    Try the following code.
    c#:
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string script = "function f(){$find(\"" + RAdwindow1.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
    }

    Thanks,
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Somy
    Somy avatar
    6 posts
    Member since:
    May 2013

    Posted 02 May 2013 Link to this post

    Thank you for helping, 
    I used the code but nothing happen when clicking for edit and the window dose not load.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 May 2013 Link to this post

    Hi,

    If you want to load the window in edit mode, try the following code.
    c#:
      protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
            if (e.CommandName == RadGrid.EditCommandName)
            {
                string script = "function f(){$find(\"" + Radwindow1.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
            }
    }

    Thanks,
    Shinu
  6. Somy
    Somy avatar
    6 posts
    Member since:
    May 2013

    Posted 03 May 2013 Link to this post

    No, I don't want to use the code at edit command.
    I want to use it at gridview selected index change. I don't know why the window didn't load.
     I deleted some properties that I used for the radwindow, and now it works.
    thank you for helping.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017