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

Float textbox in GridTemplateColumn

4 Answers 201 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexis
Top achievements
Rank 1
Alexis asked on 05 Jun 2013, 08:06 PM
So I would like to create a Grid with a Grid template column that contains a radiobutton and a textbox. On the click of the radiobutton, i want the textbox to appear to the right of the grid. Any help on starting this would be greatly appreciated.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jun 2013, 05:27 AM
Hi Alexis,

I'm not sure of your requirement,i guess you want the text box to appear right most side of grid.
Please try if this helps.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"
    AutoGenerateColumns="false" OnItemDataBound="RadGrid1_ItemDataBound">
    <MasterTableView>
        <Columns>
            <telerik:GridTemplateColumn HeaderText="Radio" UniqueName="Radio">
                <ItemTemplate>
                    <asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="true" OnCheckedChanged="RadioButton2_CheckedChanged" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn>
                <ItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" CssClass="textbox"></asp:TextBox>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
    RadioButton radio = (RadioButton)sender;
    GridDataItem gdd = (GridDataItem)radio.NamingContainer;
    TextBox txt = (TextBox)gdd.FindControl("TextBox2");
    if (radio.Checked)
    {
        txt.Visible = true;
    }
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        TextBox txt = (TextBox)item.FindControl("TextBox2");
        txt.Visible = false;
    }
}

CSS:
<style type="text/css">
    .textbox
    {
        float: right;
    }
</style>

Thanks,
Princy


0
Alexis
Top achievements
Rank 1
answered on 06 Jun 2013, 06:51 PM
Hello Princy, thank you so much for your response. I tried the code that you gave me, and its close to what I am looking for, however is there a way to remove the formatting in that column of the table so that way it looks like it is floating outside the table?
0
Alexis
Top achievements
Rank 1
answered on 07 Jun 2013, 04:59 AM
Princy, perhaps you can help me with the whole idea overall. I would like a nested grid where there is a radio button list column. The column will have an approve option and a reject option if reject is selected all the items in the child grid will automatically inherit that value as well. If the reject button is pushed, also a text box for the parent item and each child item will appear next to the corresponding row. Your help would be so greatly appreciated!!!!
0
Princy
Top achievements
Rank 2
answered on 07 Jun 2013, 05:03 AM
Hi Alexis,

You can do anything with the CSS,here is what i have done,you can change accordingly.
Set the width of the radgrid,according to how you want and set the CSS class with respective to that.I have attached a Screenshot.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server"  Width="600px">
...
...
</telerik:RadGrid>

CSS:
.textbox
{
 float: right;
 margin-left: 180px;
 margin-top: -10px;
 padding-left: 10px;
 position: absolute;
}

Thanks
Princy
Tags
Grid
Asked by
Alexis
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Alexis
Top achievements
Rank 1
Share this question
or