.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

gridview postback on editTemplate

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net

Hi Experts ,

Not sure whether this is possible even.

I have a gridview with EditTemplate. The column headings in the database for the gridview ProjectID(Unique),ProjectName,IsSubproject(Yes or No flag), SubprojectName.

If the IsSubproject column in the gridview is a checkbox while the SubprojectName is selected from a dropdown list. If checkbox is checked in edit mode I need to enable the dropdown list. Here is one postback I need.

In the dropdown list there is all the subprojects from the database and a new item "AddNew". If the user selects "AddNew" I need to enable and make visible true a textbox so that user can enter a new subproject. Here is the other postback I need.

Can I do these?

Some code help would be great.

View Complete Post

More Related Resource Links

Maintain HTML Radio Button Selection Inside GridView After Postback

Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.

GridView Paging Postback

I have to DataGrids on same page and they both got paging on that cause postback. Now on every single post back i want to find which DataGrid Paging caused the post back this time... Any Ideas?

GridView EditTemplate DropDownLists' Loads fire before SelectedIndexChanged events on AutoPostBack=

My GridView allows EditTemplate but no DataSource in the aspx page. I set the DataSource & DataBind in code behind. My problem is with 2 of the 4 DropDownLists: they require AutoPostBack=true b/c the load of ddlDptmtGrid is dependant on the selection from ddlOrgGrid, and the load of ddlPosGrid is dependant on the selection from ddlDptmtGrid. The problem lies in that every postback calls each ddl's load & then the SelectedIndexChanged event, by this point the SelectedValue has been reset or wiped. And i can't use "if (!IsPostBack) { }" b/c the initial click of the lnkEditBtn is a postback & the DropDownLists don't even exist till in Edit Mode, so i need this initial load. But it appears on every postback all the controls in Edit mode are wiped & re-initialized, so it forces each DDL to be re-declared & re-loaded, but then the SelectedValue (which caused the postback) cannot be remembered?<asp:GridView ID="gridPendRoles" runat="server" CellPadding="5" AutoGenerateColumns="False" BackColor="#CCFFFF" BorderColor="Black" BorderStyle="Solid" onrowdeleting="gridPendRoles_RowDeleting" onrowediting="gridPendRoles_RowEditing" onrowcancelingedit="gridPendRoles_RowCancelingEdit" onrowupdating="gridPendRoles_RowUpdating"

1st PostBack only: SelectedIndexChanged events fire AND GridView & ReadOnly controls disappear

On initial load of the page, everything is visible & runs correct. On the first PostBack fired by any one of my DDLs, RadioBtns, LinkBtns that have the AutoPostBack=true property, then ddlPriority_SelectedIndexChanged & ddlPendUserReqType_SelectedIndexChanged events always fire (and only from these DDLs, the others don't fire inappropriately), even when neither of those controls had been selected. Then my GridView gridPendRoles disappears, unless a DataSource & DataBind() is forced. Any ReadOnly controls (lblTicketID, txbxInsertTicketDate, lblPendUserID) will also loose their data/text in the first PostBack. However, every PostBack following will not inappropriately fire events. And as long as a DataSource was set & DataBind() called a 2nd time at any time during any PostBack, the GridView will stay visible with correct data displayed. Again, as long as the ReadOnly controls have their data/text set a 2nd time during any PostBack, they too will retain their data/text for every following PostBack. I've tried debugging with Trace on & walked thru everything very thoroughly, but still cannot catch any reasons why this would occur. And since I am using the Delete & Edit command linkBtns in my GridView, I can't just force a DataSource & DataBind() on every PostBack, or I would loose those Row

Gridview attribute changed by javascript is lost on postback

I have a gridview control that extends the default gridview.  I have added an attribute called "hiddenSelectedValues" to to the gridview during the "PreRender" event and I have a private variable that points to the value of that attribute. I have some javascript code that modifies the value of this attribute based on the user checking or unchecking checkboxes in the grid.  I have confirmed that the javascript is indeed modifying the value of the "hiddenSelectedValues" attribute by using Firebug to see the change as it happens. However, once a postback occurs, the grid looses the updated value of this attribute and I am unable to reference get the updated value on the server side. How do I keep the value of an attribute changed by javascript on postback?

gridview viewstate (size around 1.75Mb on each postback) very serious problem

i am developing a a web application of a general store where the operator has to enter the things what cutomer has purchased..like daily useage item,or anyhing ..so i have form in which i first ask how much item u wanna regsiter...(if he has 20-30 number of items then operator will eneter 20-30 then in gridview 20-30 item are opened...with bind dropdownbox containing name of item ,then textboxs containing mrp,value,stock avail of that item .here is the link for demo... http://iconsoftech.com/mahajan/grid/gridview_test.aspxproblem is suppose the operator enter the value above 20.. then then viewstate size id about 1.50Mb thats too heavey please suggest me solution for this problem..<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gridview_test.aspx.cs" Inherits="gridview_test" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label4" runat="server" Text="Enter No. Of Products"></asp:Label&g

Persist Images in Gridview after postback


Hello friends, I have a grid view whose 1st column is Image Field. Now I assign 1 out of 4 images to each row at runtime. I have this gridview in ajax updatepanel. Now how can i persist the images in the first column after a postback.

Gridview in postback no showing up


Hey All, 

I am trying to create a form that displays a dropdown and a password. The dropdown will act as the login for the password. If the password is correct the dropdown should be the variable for a gridview that should be visible? Can someone look at my code and see where I may be going wrong or any hints?

ASP Code

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="RtlFormStoreSubmittedForms.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Forms Submitted</title>
    <style type="text/css">
            height: 676px;
    <form id="form1" runat="server">

    <asp:SqlDataSource ID="SqlDSStoreNum" runat="server" 
        ConnectionString="<%$ ConnectionStrings:samConnectionString %>" 
        SelectCommand="select Store, Store +' - '+Store_name as StoreName, replace(id_cont,'01','')as id_cont from stores where a

losing gridview row value on postback


i have a global field called hotelId. i then have this piece of code that gets a value from gridview row:

        protected void gvHotel_SelectedIndexChanged(object sender, EventArgs e)
            if (Page.IsPostBack)
                int hotelId = (int)gvHotel.SelectedDataKey.Value;

the local variable is assigned to my global one, which gets passed to my method along with other variables. while stepping through i can see the value is set, but when i hit the submit button variabl is passed to another method except my hoteId. it gets lost...

Inplace Edit in GridView

In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.

GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

AJAX GridView Paging and Sorting using C# in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

GridView Paging Using Ajax in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend