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

Problem in Changing of controls in Radgrid

2 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Harees
Top achievements
Rank 1
Harees asked on 03 Jan 2013, 09:09 AM
Hi All!

In my rad grid ,am using one label control and when we click on the label the label control should be changed to text box control and the value binded  in the label now it want to display in the text box control.

am using the label and textbox control in same grid template column.on initial loading am declaring the textbox visible to false.


thanks for ur help..........

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Jan 2013, 10:26 AM
Hi,

Here is the sample code that I tried based on your scenario.
aspx:
<style type="text/css">
        .class1
        {
            visibility: hidden;
        }
        .class2
        {
            visibility: visible;
        }
    </style>
<telerik:GridTemplateColumn>
     <ItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" CssClass="class1" Text='<%# Eval("OrderID") %>'></asp:TextBox>
        <asp:Label ID="Label1" runat="server" Text='<%# Eval("OrderID") %>'></asp:Label>
    </ItemTemplate>
</telerik:GridTemplateColumn>
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
  {
          GridDataItem item = (GridDataItem)e.Item;
          Label lbl = (Label)item.FindControl("Label1");
          lbl.Attributes.Add("onClick", "test('"+ lbl.ClientID +"');");
  }
}
JS:
function test(id) {
  var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
        var row = masterTable.get_dataItems();
        for (var i = 0; i < row.length; i++)
      {
           masterTable.get_dataItems()[i].findElement("TextBox1").className = "class2";
            masterTable.get_dataItems()[i].findElement("Label1").className = "class1";
}
    }

Thanks,
Shinu.
0
Harees
Top achievements
Rank 1
answered on 03 Jan 2013, 10:59 AM
Thanks shinu....

but i have tried like this..

C#
lbl.Attributes.Add("onClick", "test('"+ lbl.ClientID +"','"+ txt.ClientID +"');");

JS

function test(lbl,txt) {
            var radGrid= $find("<%= radGrid.ClientID %>");
            var txt = document.getElementById(txt);
            var lbl= document.getElementById(lbl);
 
            lbl.style.display = 'none';
            txt.style.display = 'block';
}

Tags
Grid
Asked by
Harees
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Harees
Top achievements
Rank 1
Share this question
or