473,394 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

unable to edit the gridview edit eventhough gridview outside the updatepanel

I am unable to edit the gridview edit eventhough gridview outside the updatepanel.

Expand|Select|Wrap|Line Numbers
  1. <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  2.     <div>
  3.     <asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>
  4.         <asp:UpdatePanel runat="server" ID="UPDATEPANEL1">
  5.             <ContentTemplate>
  6.                 <asp:DropDownList ID="pnddl" runat="server" AutoPostBack="true" 
  7.                     onselectedindexchanged="pnddl_SelectedIndexChanged">
  8.                     <asp:ListItem Text="--select project--" Value=""></asp:ListItem>
  9.                 </asp:DropDownList>
  10.                 <asp:DropDownList ID="gbddl" runat="server" AutoPostBack="true" 
  11.                     onselectedindexchanged="gbddl_SelectedIndexChanged">
  12.                     <asp:ListItem Text="--select name--" Value=""></asp:ListItem>
  13.                 </asp:DropDownList>
  14.                 <asp:DropDownList ID="clientddl" runat="server">
  15.                     <asp:ListItem Text="--select client--" Value=""></asp:ListItem>
  16.                 </asp:DropDownList>
  17.                 <asp:Button Text="GO" ID="gobtn" runat="server" onclick="Unnamed1_Click" />
  18.             </ContentTemplate>
  19.             <Triggers>
  20.                 <asp:PostBackTrigger ControlID="gobtn" />
  21.  
  22.             </Triggers>
  23.         </asp:UpdatePanel>
  24.     </div>
  25.     <div>
  26.         <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
  27.             AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="project_id" 
  28.             DataSourceID="SqlDataSource1" onrowediting="GridView1_RowEditing">
  29.             <Columns>
  30.                 <asp:BoundField DataField="project_id" HeaderText="project_id" 
  31.                     InsertVisible="False" ReadOnly="True" SortExpression="project_id" />
  32.                 <asp:BoundField DataField="project_name" HeaderText="project_name" 
  33.                     SortExpression="project_name" />
  34.                 <asp:BoundField DataField="language" HeaderText="language" 
  35.                     SortExpression="language" />
  36.                 <asp:BoundField DataField="dateoftaken" HeaderText="dateoftaken" 
  37.                     SortExpression="dateoftaken" />
  38.                 <asp:BoundField DataField="dateoffinish" HeaderText="dateoffinish" 
  39.                     SortExpression="dateoffinish" />
  40.                 <asp:BoundField DataField="extendeddate" HeaderText="extendeddate" 
  41.                     SortExpression="extendeddate" />
  42.                 <asp:BoundField DataField="extendeddays" HeaderText="extendeddays" 
  43.                     SortExpression="extendeddays" />
  44.                     <asp:CommandField ShowEditButton="true" CausesValidation="false"/>
  45.             </Columns>
  46.         </asp:GridView>  
  47.         <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
  48.             ConnectionString="<%$ ConnectionStrings:project_dbConnectionString %>" 
  49.             SelectCommand="SELECT [project_id], [project_name], [language], [dateoftaken], [dateoffinish], [extendeddate], [extendeddays] FROM [project] WHERE ([project_id] = @project_id)">
  50.             <SelectParameters>
  51.                 <asp:SessionParameter Name="project_id" SessionField="project_id" 
  52.                     Type="Int32" />
  53.             </SelectParameters>
  54.         </asp:SqlDataSource>
  55.     </div>
  56.     <div>
  57. asp.net code:
  58.  
  59.  
  60.  
  61. protected void Page_Load(object sender, EventArgs e)
  62.     {
  63.         if (!IsPostBack)
  64.         {
  65.             pnddl.AppendDataBoundItems = true;
  66.             populatedroplist.populatedropdown(pnddl, "project", "project_name");
  67.         }
  68.  
  69.     }
  70.     Find_class findobj = new Find_class();
  71.     protected void pnddl_SelectedIndexChanged(object sender, EventArgs e)
  72.     {
  73.         gbddl.Items.Clear();
  74.         gbddl.Items.Add(new ListItem("--select country--", ""));
  75.         gbddl.AppendDataBoundItems = true;
  76.         clientddl.Items.Clear();
  77.         clientddl.Items.Add(new ListItem("--select client--", ""));
  78.         clientddl.AppendDataBoundItems = true;
  79.         string project_name = pnddl.SelectedValue;
  80.         int project_id = Convert.ToInt32(findobj.getcolumn("project_id", "project", "project_name", project_name));
  81.         populatedroplist.populatedropdownbycolumn(gbddl, "givenby", "personname", "project_id", project_id);
  82.          populatedroplist.populatedropdownbycolumn(clientddl, "client", "clientname", "project_id", project_id);
  83.  
  84.     }
  85.     protected void gbddl_SelectedIndexChanged(object sender, EventArgs e)
  86.     {
  87.         clientddl.Items.Clear();
  88.         clientddl.Items.Add(new ListItem("--select client name--", ""));
  89.         clientddl.AppendDataBoundItems = true;
  90.         string project_name = pnddl.SelectedItem.Value;
  91.         int project_id = Convert.ToInt32(findobj.getcolumn("project_id", "project", "project_name", project_name));
  92.         populatedroplist.populatedropdownbycolumn(clientddl, "client", "clientname", "project_id", project_id);
  93.     }
  94.     protected void Unnamed1_Click(object sender, EventArgs e)
  95.     {
  96.         if (IsPostBack)
  97.         {
  98.             int project_id;
  99.             string project_name = pnddl.SelectedValue.ToString();
  100.             string personname = Convert.ToString(gbddl.SelectedValue);
  101.             string clientname = Convert.ToString(clientddl.SelectedValue);
  102.             project_id = Convert.ToInt32(findobj.getcolumn("project_id", "project", "project_name", project_name));
  103.             int person_id = Convert.ToInt32(findobj.getcolumn("person_id", "givenby", "personname", personname));
  104.             //int client_id = Convert.ToInt32(findobj.getcolumn("client_id", "client", "clientname", clientname));
  105.             Session["project_id"] = project_id;
  106.             Session["person_id"] = person_id;
  107.             Session["personname"] = personname;
  108.             GridView1.DataBind();
  109.             GridView1.Visible = true;
  110.         }
  111.         //Session["client_id"] = client_id;
  112.     }
  113.     protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  114.     {
  115.         GridView1.EditIndex = e.NewEditIndex;
  116.     }



Please help by providing solution as soon as possible
Aug 14 '11 #1
3 2302
Frinavale
9,735 Expert Mod 8TB
Are you preforming a DataBind on the GridView in your Page's Load or PreRender event?

Could you please provide more information about what the problem is?

What do you mean by "can't edit the GridView"?

Does this mean that the fields don't become editable when you click the edit button...does this mean that your data source is not updated when the user clicks the update button...what exactly is going wrong?

-Frinny
Sep 2 '11 #2
Hi Frinny,

Thank you for your response.

Your correct.The fields donot become editable and also datasource is not updated when user clicks the update button.

I am binding the values in page load event.
and the same problem is happeninng for dropdown boxes.I have three cascading dropdownlists.Once the user selected the first dropdown list item then the second dropdown list gets enabled and the items will append to the second one.But this is not going fine.If i again reload the page then the items are appending.

So please help me what i am missing out here.


Regards,
Mohan.
Sep 3 '11 #3
Frinavale
9,735 Expert Mod 8TB
Move the databind to the Page's PreRender event instead.
When you do the databind in the Page Load event the source is reset back to what it was originally and the editing will never take place.

-Frinny
Sep 6 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the...
6
by: ibiza | last post by:
Hi all, I have a gridview that can edit data, which is bound to an sqldatasource. Everything works fine, I can update the data via an Edit Command field. However, there are some textboxes in...
2
by: David Ching | last post by:
I am not getting any response to my previous question on reusing a DetailsView to insert and edit the selected row in a GridView. So I'll ask an even more basic question. Newbie alert! ;) When...
1
by: =?iso-8859-1?B?R2VhcvNpZA==?= | last post by:
Strange problem... Have a gridview on a page (within an update panel) for displaying event dates. GridView loads fine first time around with the PageLoad. There are 2 text fields a user can...
2
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm in a gridview edit row that has a DropDownList in one column and a status Label in the 2nd column. When i changed the value in the dropdownlist, there's a client-side javascirpt...
1
by: J | last post by:
I like the Edit (Update, Cancel) functionality built into the gridview, but I'd like to control what happens when the Update is clicked. I would like to prompt the user with something like this...
0
by: Andy B | last post by:
I have a GridView in asp.net. I want to set its datasource to some xml content. At the same time, I need to know how to insert/delete/edit content in the GridView rows and then repopulate the xml...
1
by: Lakshmi GagniShetty | last post by:
In gridview edit event it is possible to display dropdownlist instead of text boxes.I am using dotnet 2005. Here the gridview autogenerate columns are false. And I had only one row and columns...
0
parshupooja
by: parshupooja | last post by:
Hey All, I have where I want to do some manipulations and show in other column but unable to find their values in RowDatabound event even though I have two records in gridview <asp:GridView...
11
by: bala venkata siva ram kum | last post by:
I am facing a problem while clicking edit button of a gridview.after clicking edit button it is displaying empty textboxes. I need old values in that textboxes. Here i used 3-tier architecture....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.