Hi vrindavani,
Check the below sample code.
HTML
<label>Type</label>
<asp:DropDownList ID="drptype" runat="server" AutoPostBack="true" OnSelectedIndexChanged="OnSelectedIndexChanged">
<asp:ListItem Text="A" Value="A"></asp:ListItem>
<asp:ListItem Text="B" Value="B"></asp:ListItem>
</asp:DropDownList>
<label>Type</label>
<asp:DropDownList ID="drpsubname" runat="server">
<asp:ListItem Text="A1" Value="A1"></asp:ListItem>
<asp:ListItem Text="A2" Value="A2"></asp:ListItem>
<asp:ListItem Text="B1" Value="B1"></asp:ListItem>
<asp:ListItem Text="B2" Value="B2"></asp:ListItem>
</asp:DropDownList>
<br />
<label>Paragraph1</label>
<asp:TextBox ID="txt_paragraph1" runat="server" CssClass="form-control" placeholder="Please Enter Your Paragraph " TextMode="MultiLine" Height="90"></asp:TextBox>
<br />
<asp:Button Text="Save" runat="server" OnClick="OnSave" />
Code
C#
vrindavani
protected void OnSelectedIndexChanged(object sender, EventArgs e)
{
string selectedType = drptype.SelectedValue;
foreach (ListItem item in drpsubname.Items)
{
drpsubname.ClearSelection();
if (!item.Value.StartsWith(selectedType))
{
drpsubname.Items.FindByValue(item.Value).Attributes.Add("disabled", "disabled");
drpsubname.Items.FindByValue(item.Value).Attributes.Add("style", "display:none");
}
else
{
drpsubname.Items.FindByValue(item.Value).Selected = true;
}
}
}
protected void OnSave(object sender, EventArgs e)
{
string type = drptype.SelectedValue;
string subType = drpsubname.SelectedValue;
string para = txt_paragraph1.Text;
// Write code to save in database.
}
VB.Net
Protected Sub OnSelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim selectedType As String = drptype.SelectedValue
For Each item As ListItem In drpsubname.Items
drpsubname.ClearSelection()
If Not item.Value.StartsWith(selectedType) Then
drpsubname.Items.FindByValue(item.Value).Attributes.Add("disabled", "disabled")
drpsubname.Items.FindByValue(item.Value).Attributes.Add("style", "display:none")
Else
drpsubname.Items.FindByValue(item.Value).Selected = True
End If
Next
End Sub
Protected Sub OnSave(ByVal sender As Object, ByVal e As EventArgs)
Dim type As String = drptype.SelectedValue
Dim subType As String = drpsubname.SelectedValue
Dim para As String = txt_paragraph1.Text
' Write code to save in database.
End Sub
For saving multiline textbox refer below links.