i have gridview and inside gridview i have 2 dropdownlist
on selected indexchanged of 1st DDL then 2nd DDL bind
on selected indexchanged of 2nd DDL then textbox filled with any value
on aspx i used master page.
after select index changed page is reload
i want page should not be reload and my working is all done.
how to achieve it in VB.Net
Loading
Adarsh NigamPosted Aug 17, 2024, 5:37 PM
To achieve this without a full page reload, you can use ASP.NET's built-in AJAX functionality, specifically the
UpdatePanelcontrol. Here's an example of how you can modify your ASPX page to achieve this:Code Behind
Protected Sub ddl1_SelectedIndexChanged(sender As Object, e As EventArgs)
' Bind ddl2 based on ddl1 selection
Dim ddl1 As DropDownList = DirectCast(sender, DropDownList)
Dim ddl2 As DropDownList = DirectCast(ddl1.NamingContainer.FindControl("ddl2"), DropDownList)
' Bind ddl2 items
ddl2.DataSource = ' your data source
ddl2.DataBind()
End Sub
Protected Sub ddl2_SelectedIndexChanged(sender As Object, e As EventArgs)
' Fill txtBox based on ddl2 selection
Dim ddl2 As DropDownList = DirectCast(sender, DropDownList)
Dim txtBox As TextBox = DirectCast(ddl2.NamingContainer.FindControl("txtBox"), TextBox)
' Fill txtBox with value
txtBox.Text = ' your value
End Sub
By using the
UpdatePanelcontrol, you can update the contents of the panel without causing a full page reload. TheTriggerssection specifies which controls will trigger an asynchronous postback.In the code-behind, you can access the controls within the
UpdatePanelusing theNamingContainerproperty.Make sure to add the
ScriptManagercontrol to your Master Page, and setEnablePartialRenderingtotrue.This should achieve the desired behavior without a full page reload.