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

[Solved] Show Label & TextBox When I select Data In ComboBox

3 Answers 206 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yoon-Ho Choi
Top achievements
Rank 1
Yoon-Ho Choi asked on 30 Dec 2009, 05:23 AM
Hi, All

When I Select some Data in ComboBox At EditForm

I wanna show some TextBox

And when I select another data in combobox

I wanna TextBox not visible


Also

I want to put some color in specific (Row, column)

like

<tr>
    <td bgcolor="#666666">&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#222222">&nbsp;</td>
</tr>

Please Help me

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 30 Dec 2009, 07:20 AM
Hi Yoon-Ho Choi,

You can try the following code in order to set the Visibility according to the RadComboBox item that user selects.

aspx:
 
<EditFormSettings EditFormType="Template"
    <FormTemplate> 
        <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"
            <Items> 
                <telerik:RadComboBoxItem Text="Item1" Value="Value1" /> 
                <telerik:RadComboBoxItem Text="Item2" Value="Value2" /> 
            </Items> 
        </telerik:RadComboBox> 
        <asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox> 
    </FormTemplate> 
</EditFormSettings> 

cs:
 
protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    RadComboBox combo = (RadComboBox)o; 
    GridEditFormItem editItem = (GridEditFormItem)combo.NamingContainer; 
    TextBox textbox1 = (TextBox)editItem.FindControl("TextBox1"); 
    if (e.Text == "Item1"
    { 
        textbox1.Visible = true
    } 
    else if (e.Text == "Item2"
    { 
        textbox1.Visible = false
    } 

Checkout the following link that will help you in setting color/style for specific cell in grid based on condition.
Conditional Formatting for rows/cells on ItemDataBound

Also checkout the following links:
Grid / Accessing Cells and Rows
Accessing cells and rows

-Shinu.
0
Yoon-Ho Choi
Top achievements
Rank 1
answered on 30 Dec 2009, 09:36 AM
Thank you Shinu

It's helpful to me

but put color in column looking difficult..

Anyway Thanks a lot ^^
0
Princy
Top achievements
Rank 2
answered on 30 Dec 2009, 09:58 AM
Hello,

You can either the set the back-color from the aspx declaratively or from code by accessing the item and setting the style as required.

Here is the code for setting the color declaratevely,
aspx:
 
      . . . 
    <telerik:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" 
        UniqueName="CompanyName"
        <ItemStyle BackColor="Blue" /> 
    </telerik:GridBoundColumn> 
      . . . 

And from code behind,
cs:
 
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if ((e.Item is GridDataItem)) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            item["CompanyName"].BackColor = System.Drawing.Color.Blue; 
        } 
    } 

Thanks,
Princy.
Tags
Grid
Asked by
Yoon-Ho Choi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Yoon-Ho Choi
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or