Hello, I have a simple question. Are you allowed to edit gridview columns for a gridview that resides in an Updatepanel?
I'm playing around with a simple project I created to learn more about this. If I don't have the gridview control in the updatepanel, I'm able to press the edit button on one of the rows and am able to modify the text in the column. Otherwise it won't allow me to edit the column.
Here's my markup -
<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>
-
-
-
<table style="font-family:Arial;">
-
-
<asp:GridView ID="GridView1" width="800px" runat="server" AutoGenerateColumns="false"
-
AllowSorting = "true" AllowPaging = "true" AutoGenerateDeleteButton = "false"
-
AutoGenerateEditButton = "True" AutoGenerateSelectButton = "false" PageSize = "4"
-
OnRowEditing="GridView1_RowEditing"
-
OnRowCancelingEdit="GridView1_RowCancelingEdit"
-
OnRowUpdating="GridView1_RowUpdating"
-
OnPageIndexChanging="GridView1_PageIndexChanging"
-
PagerSettings-Mode = "NextPreviousFirstLast"
-
BorderWidth="1px" BackColor="White" GridLines="Vertical"
-
CellPadding="4" BorderStyle="None"
-
BorderColor="#DEDFDE" ForeColor="Black">
-
<FooterStyle BackColor="#CCCC99"></FooterStyle>
-
<PagerStyle ForeColor="Black" HorizontalAlign="Right"
-
BackColor="#F7F7DE"></PagerStyle>
-
<HeaderStyle ForeColor="White" Font-Bold="True"
-
BackColor="#6B696B"></HeaderStyle>
-
<AlternatingRowStyle BackColor="LightGray"></AlternatingRowStyle>
-
-
<Columns>
-
-
<%--
-
<asp:TemplateField>
-
<ItemTemplate>
-
<asp:CheckBox runat="server" ID="RowLevelCheckbox" />
-
</ItemTemplate>
-
</asp:TemplateField> --%>
-
-
-
<asp:BoundField DataField="distrib_zone_id" headertext = "Distrib Zone Id" ReadOnly = "false" sortexpression = "distrib_zone_id" ItemStyle-Width = "200" />
-
-
<asp:BoundField DataField="distrib_zone_desc" headertext = "Distrib Zone Desc" ReadOnly = "false" sortexpression = "distrib_zone_desc" ItemStyle-Width = "600" />
-
-
<asp:BoundField DataField="district_id" headertext = "District Id" ReadOnly = "false" sortexpression = "district_id" ItemStyle-Width = "375" />
-
-
<asp:BoundField DataField="carrier_id" headertext = "Carrier Id" ReadOnly = "false" sortexpression = "carrier_id" ItemStyle-Width = "375" />
-
-
<asp:BoundField DataField="carrier_full_name" headertext = "Carrier Name" ReadOnly = "false" sortexpression = "carrier_full_name" ItemStyle-Width = "700" />
-
-
<asp:BoundField DataField="partner_id" headertext = "Partner Id" ReadOnly = "false" sortexpression = "partner_id" ItemStyle-Width = "400" />
-
-
-
</Columns>
-
-
</asp:GridView>
-
-
<tr>
-
<td>
-
 
-
<br />
-
<asp:Label ID="lblWhichButton" runat="server" Text="WhichButton" Width="300px" Font-Bold="true"></asp:Label>
-
</td>
-
</tr>
-
<tr>
-
<td >
-
-
</td>
-
-
<td>
-
<asp:Label ID="lblPartners" runat="server" Text="Partners " Width="100px" Font-Bold="true"></asp:Label>
-
  
-
<asp:DropDownList id="PartnerList"
-
AutoPostBack="False"
-
runat="server"/>
-
    
-
<asp:Button ID="btn_AssignPartner" runat="server" Text="Assign Partner" />
-
<asp:Button ID="btn_RemovePartner" runat="server" Text="Remove Partner" />
-
             
-
            
-
            
-
            
-
<asp:Button ID="btn_Exit" runat="server" Text="Exit" />
-
-
</td>
-
</tr>
-
</table>
-
-
</ContentTemplate>
-
-
</asp:UpdatePanel>
1 6153
Not sure what you're doing wrong...it should work.
You're probably not binding in the right spot.
Here is what I tried based on what you posted.
Here's my ASP markup for a web form called WebForm1.aspx: - <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
-
-
<!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></title>
-
</head>
-
<body>
-
<form id="form1" runat="server">
-
<div>
-
<asp:ScriptManager ID="smanager" runat="server" />
-
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
-
<ContentTemplate>
-
<table style="font-family: Arial;">
-
<asp:GridView ID="GridView1" Width="800px" runat="server" AutoGenerateColumns="false"
-
AllowSorting="true" AllowPaging="true" AutoGenerateDeleteButton="false" AutoGenerateEditButton="True"
-
AutoGenerateSelectButton="false" PageSize="4" OnRowEditing="GridView1_RowEditing"
-
OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowUpdating="GridView1_RowUpdating"
-
OnPageIndexChanging="GridView1_PageIndexChanging" PagerSettings-Mode="NextPreviousFirstLast"
-
BorderWidth="1px" BackColor="White" GridLines="Vertical" CellPadding="4" BorderStyle="None"
-
BorderColor="#DEDFDE" ForeColor="Black">
-
<FooterStyle BackColor="#CCCC99"></FooterStyle>
-
<PagerStyle ForeColor="Black" HorizontalAlign="Right" BackColor="#F7F7DE"></PagerStyle>
-
<HeaderStyle ForeColor="White" Font-Bold="True" BackColor="#6B696B"></HeaderStyle>
-
<AlternatingRowStyle BackColor="LightGray"></AlternatingRowStyle>
-
<Columns>
-
<asp:BoundField DataField="distrib_zone_id" HeaderText="Distrib Zone Id" ReadOnly="false"
-
SortExpression="distrib_zone_id" ItemStyle-Width="200" />
-
<asp:BoundField DataField="distrib_zone_desc" HeaderText="Distrib Zone Desc" ReadOnly="false"
-
SortExpression="distrib_zone_desc" ItemStyle-Width="600" />
-
<asp:BoundField DataField="district_id" HeaderText="District Id" ReadOnly="false"
-
SortExpression="district_id" ItemStyle-Width="375" />
-
<asp:BoundField DataField="carrier_id" HeaderText="Carrier Id" ReadOnly="false" SortExpression="carrier_id"
-
ItemStyle-Width="375" />
-
<asp:BoundField DataField="carrier_full_name" HeaderText="Carrier Name" ReadOnly="false"
-
SortExpression="carrier_full_name" ItemStyle-Width="700" />
-
<asp:BoundField DataField="partner_id" HeaderText="Partner Id" ReadOnly="false" SortExpression="partner_id"
-
ItemStyle-Width="400" />
-
</Columns>
-
</asp:GridView>
-
<tr>
-
<td>
-
 
-
<br />
-
<asp:Label ID="lblWhichButton" runat="server" Text="WhichButton" Width="300px" Font-Bold="true"></asp:Label>
-
</td>
-
</tr>
-
<tr>
-
<td>
-
</td>
-
<td>
-
<asp:Label ID="lblPartners" runat="server" Text="Partners " Width="100px" Font-Bold="true"></asp:Label>
-
<asp:DropDownList ID="PartnerList" AutoPostBack="False" runat="server" />
-
<asp:Button ID="btn_AssignPartner" runat="server" Text="Assign Partner" />
-
<asp:Button ID="btn_RemovePartner" runat="server" Text="Remove Partner" />
-
<asp:Button ID="btn_Exit" runat="server" Text="Exit" />
-
</td>
-
</tr>
-
</table>
-
</ContentTemplate>
-
</asp:UpdatePanel>
-
</div>
-
</form>
-
</body>
-
</html>
Here is my C# code for the page: - using System;
-
using System.Collections.Generic;
-
using System.Linq;
-
using System.Web;
-
using System.Web.UI;
-
using System.Web.UI.WebControls;
-
-
namespace WebApplication1
-
{
-
public partial class WebForm1 : System.Web.UI.Page
-
{
-
private System.Data.DataSet oDataSet;
-
private System.Data.DataTable oDataTable;
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
//Retrieving the datasource for the grid view
-
if (Session["oDataSet"] != null)
-
{
-
oDataSet = (System.Data.DataSet)Session["oDataSet"];
-
}
-
else
-
{
-
createDataTable();
-
Session["oDataSet"] = oDataSet;
-
}
-
-
}
-
-
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
-
{
-
//Setting the page indext to the new page index
-
GridView1.PageIndex = e.NewPageIndex;
-
}
-
-
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
-
{
-
//Retrieve the table from the session object.
-
System.Data.DataTable dt = oDataSet.Tables[0];
-
-
//Update the values.
-
GridViewRow row = GridView1.Rows[e.RowIndex];
-
dt.Rows[row.DataItemIndex]["distrib_zone_id"] = ((TextBox)(row.Cells[1].Controls[0])).Text;
-
dt.Rows[row.DataItemIndex]["distrib_zone_desc"] = ((TextBox)(row.Cells[2].Controls[0])).Text;
-
dt.Rows[row.DataItemIndex]["district_id"] = ((TextBox)(row.Cells[3].Controls[0])).Text;
-
dt.Rows[row.DataItemIndex]["carrier_id"] = ((TextBox)(row.Cells[4].Controls[0])).Text;
-
dt.Rows[row.DataItemIndex]["carrier_full_name"] = ((TextBox)(row.Cells[5].Controls[0])).Text;
-
dt.Rows[row.DataItemIndex]["partner_id"] = ((TextBox)(row.Cells[6].Controls[0])).Text;
-
//Reset the edit index.
-
GridView1.EditIndex = -1;
-
-
}
-
-
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
-
{ //Cancelling the edit
-
GridView1.EditIndex = -1;
-
}
-
-
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
-
{ //Setting the edit index to the row that is being edited
-
//This is probably not going to wrok with paging
-
GridView1.EditIndex = e.NewEditIndex;
-
}
-
void Page_PreRender(object sender, EventArgs e)
-
{ //Setting the data source for the gridview and binding to the data
-
GridView1.DataSource = oDataSet;
-
GridView1.DataBind();
-
}
-
-
private void createDataTable()
-
{ //Since I don't have a database, I'm creating a data set and adding
-
//a data table to the data set with populated default data
-
oDataSet = new System.Data.DataSet();
-
oDataTable = new System.Data.DataTable();
-
-
oDataTable.Columns.Add("distrib_zone_id", typeof(string));
-
oDataTable.Columns.Add("distrib_zone_desc", typeof(string));
-
oDataTable.Columns.Add("district_id", typeof(string));
-
oDataTable.Columns.Add("carrier_id", typeof(string));
-
oDataTable.Columns.Add("carrier_full_name", typeof(string));
-
oDataTable.Columns.Add("partner_id", typeof(string));
-
for (int i = 0; i < 10; i++)
-
{
-
System.Data.DataRow oDataRow = oDataTable.NewRow();
-
string distrib_zone_id = String.Format("{0}{1}", "distrib_zone_id", i);
-
string distrib_zone_desc = String.Format("{0}{1}", "distrib_zone_desc", i);
-
string district_id = string.Format("{0}{1}", "district_id", i);
-
string carrier_id = string.Format("{0}{1}", "carrier_id", i);
-
string carrier_full_name = string.Format("{0}{1}", "carrier_full_name", i);
-
string partner_id = string.Format("{0}{1}", "partner_id", i);
-
DateTime updatetime = DateTime.Now;
-
oDataRow[0] = distrib_zone_id;
-
oDataRow[1] = distrib_zone_desc;
-
oDataRow[2] = district_id;
-
oDataRow[3] = carrier_id;
-
oDataRow[4] = carrier_full_name;
-
oDataRow[5] = partner_id;
-
oDataTable.Rows.Add(oDataRow);
-
}
-
-
oDataSet.Tables.Add(oDataTable);
-
-
}
-
}
-
}
Check out the code I posted and see if you're doing something differently with regards to binding or something...
We can discuss any differences that you have if you'd like.
Like I said, it works fine for me.
-Frinny
Sign in to post your reply or Sign up for a free account.
Similar topics
by: brett |
last post by:
I have an AJAX updatepanel in an aspx page. Inside the updatepanel is
a placeholder control, which loads various ascx files. This all works
fine. One of the ascx files also has an updatepanel in...
|
by: Reinhard |
last post by:
Hi,
Need some directions on Ajax, UpdatePanel and Gridview to achive the
following:
I like to show a Gridview with Data ONLY if the user is interested in
Details, but without a full page...
|
by: =?Utf-8?B?TWlrZQ==?= |
last post by:
Hi,
I have a Wizard that have about 5 steps and in every step (page) I do have
some tables, checkboxes, gridview...etc and I'm trying to Cut and Paste this
wizard into Ajax UpdatePanel for Ajax...
|
by: SachinSachin |
last post by:
Hi All,
I am implementing a custom gridview control, that emits some javascript to blink a row whenever a new row is added in gridview. The gridview is inside the <asp:updatepanel> for...
|
by: rsdev |
last post by:
Hi,
I have read hundreds of post regarding this issue, but none have an answer for my situation. So hopefully somebody here can help!
I have a gridview in an updatepanel (AJAX control toolkit)...
|
by: Don |
last post by:
I have a GridView inside an UpdatePanel. This GridView has a command
field (edit, update, cancel). When I click edit I go into update
mode, refreshing only the GridView, as you would expect. ...
|
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...
|
by: foolmelon |
last post by:
Before AJAX, we were able to focus a cell in a gridview during a
fullpage postback. After putting the gridview inside an UpdatePanel,
we cannot focus a cell in this gridview anymore. Does anybody...
|
by: lisles |
last post by:
Hi.i want to use a ajax updatepanel.on postnack i only want the datalist "dlEvnt" to get refreshed.but thats not happening.can anybody tell me what to do.
Here's my code
edit: massive code block...
|
by: Kishore Jangid |
last post by:
I have placed a Ajax UpdatePanel to a webpage. When i click a button the data from the server are called and are fed into a HtmlGenericControl and then added to the Content of the UpdatePanel.
Now...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |