Is partial page reload possible in asp.net? - c#

I got 2 .aspx pages ,
page one(1) to insert data .....
page two(2) to view data using a gridview.
There's an edit button in the gridview , it will redirect the to page(1) and load the specific values to the textboxes, dropdowns according to the selected record.
Session is used to carry out the record from page(1) to page(2).
In the page load of page(1), if Session is not NULL it will load the values to the textboxes and etc.
My problem is , I have enabled Autopostback=true in one of the dropdowns,(to enable few more textbox's to appear when specific options are selected).
So when those options are selected page will be reloaded,when reloading it will load the specific values to the textboxes .... as the Session is not null. And the purpose of dropdown is not fulfilled because it keeps loading values to the textboxes , but not enabling the textboxes which i need to appear + the value of the selected dropdown doesnt get changed to the selected value as it loads values from the database to the dropdown too.
Any solutions ?

I sounds like you're looking for a partial postback solution.
The UpdatePanel should solve this for you:
http://www.encodedna.com/2013/02/aspdotnet.postback-updatepanel.htm

Related

How to keep textbox value and gridview value after Edit gridview record page navigation

I have a web form which is basically a search form where user should be able to search records based on ID, Date and some other criteria. The search result will be then display on gridview. I have Edit functionality for each records on the gridview.
When user click on Edit of any record it will navigate to the edit page where user should be able to edit and update.
Everything works fine upto here.
But i have a back button on the Edit page once i click on the back page it will come back to the search page.
I want to keep the previously searched value on the textbox and the search result on the gridview too but i am not able to.
I tried both session variable and cookies but it is not working.
So please help me how can i do this??
Thanks for your suggestion.

Form View page redirect

I am using a FormView to display data with a SqlDataSource and my platform is MSVS2013.
Lets say I have 4 data in Data table so it displays fist data set with page numbers at the bottom.
But if I select 2nd or 3rd on any other page number then it will refresh the page and set proper data in the FormView. The problem is if I select any other page number it will change data and not navigate view back to same position to the page, instead it shows the top position of the page.
Can any one help Thanks in advance!
Use update panel... it will give the solution

Dropdownlist data not insert in query in asp.net page

I placed five dropdownlists and three textboxes in asp.net webpage. The value select in dropdownlist and insert in textboxes are the values to be insert in query for where condition. Now the problem is that when I press search button for execution the values from text boxes are inserted in query but the dropdownlist values remain empty, and the result is not showing. I check code for dropdownlist like:
ddlChannel.SelectedValue;
ddlChannel.Text;
ddlChannel.SelectedItem;
but not any selected value is inserted from the query. Either problem in on pageLoad. I use Page_Prerender method to load dropdownlist from database through query execution. Any idea what the problem might be?
the selected values from your dropdownlists are most likely reset on postback ( when you click search button )
you can use the following code to avoid resetting your dropdownlists
if(!Page.IsPostBack)
{
//Bind dropdown lists logic
}
you have to set controls autopostback property true, eventvalidation set false on page pl

c# : Is it possible to user DropDownList of an .aspx page in DropDownList of GridView of other page?

I am having DropDownList with country name list in my .aspx page and on other page I need the same DropDownList with same data but in GridView.
Is it possible to use that DropDownList ?
You should create a user control that contains this behavior and then you can this user control in several places.
Yes. just create another dropdown box and fill in the same database data in the dropdown inside the gridview.

Dropdown list selected item always set to default value

I wish to pass values of the selected items into a database and however noticed that the selected item is not what is sent into the database you can see in the snap shot below.
during run time the following value is recorded.
Where did it all go wrong with the dropdown lists selected item?
Counting on your intelligence...thanks.
Put your call to load the dropdownlist in
if (!Page.IsPostBack)
{
//LoadDropdownListHere();
}
Try DBNull.Value instead of null.
Edit:
I think you need to specify the type using this overload: http://msdn.microsoft.com/en-us/library/cc491445.aspx
CSMDataSource.InsertParameters.Add("CaseID", DBType.Int32, CaseIDDropDownList.SelectedItem.Text);
I found the problem for the dropdownlist always selecting the first value. It appears the dropdown list is always rebinded anytime i click a button that requires a post pack as such the data tha was binded at page load re binds a gain before the selected item gets picked as such the default first value gets picked all the time. to solve my problem i first disabled enable auto postback on the dropdownlist and in the code behind that is my .cs file during the page load, where i first binded the data to the dropdown list, i used a condition like if(!ispostback) to bind my data. what this does is when the page loads first time the dropdownlist is binded and if i should select an item from the drop down list, the "auto post back" that i disabled earlier on keeps the selected item selected and when i click and button that requires a post to the server, the (!ispostback) prevents the dropdownlist to be binded again before selection. so in effect, the selection is done first and afterwards if the page should load anew, the drop down list is binded again.
i was in a bit of a rush while typing so please bare with my typo errors. do call in anytime for more clarification...peace

Categories

Resources