Hello!
I'm building a GridView using code to add template fields, because
there is a random number of columns in result set from database. I'm
using a class with ITemplate interface for defining columns. I am
using a code which adds a checkbox for each column:
public void InstantiateIn(System.Web.UI.Control container)
{
switch (templateType)
{
case DataControlRowType.DataRow:
CheckBox cb = new CheckBox();
cb.Enabled = true;
cb.ID = columnName;
cb.DataBinding += new
EventHandler(this.CB_DataBinding);
container.Controls.Add(cb);
break;
default:
break;
}
}
When I display the grid, everything looks fine, but when the page is
postback and GridView_RowUpdating event occurs, I'm unable to find any
checkbox using GridView.Rows[e.RowIndex].FindControl method. I am able
only to find empty TableCells.
I have no more ideas how to solve this problem, please help me. 4 9004
Do you instantiate the template in every request? Best way to do it would be
in OnInit event of the Page.
--
Teemu Keiski
AspInsider, ASP.NET MVP http://blogs.aspadvice.com/joteke http://teemukeiski.net
<be*******@gmail.comwrote in message
news:11********************@g4g2000hsf.googlegroup s.com...
Hello!
I'm building a GridView using code to add template fields, because
there is a random number of columns in result set from database. I'm
using a class with ITemplate interface for defining columns. I am
using a code which adds a checkbox for each column:
public void InstantiateIn(System.Web.UI.Control container)
{
switch (templateType)
{
case DataControlRowType.DataRow:
CheckBox cb = new CheckBox();
cb.Enabled = true;
cb.ID = columnName;
cb.DataBinding += new
EventHandler(this.CB_DataBinding);
container.Controls.Add(cb);
break;
default:
break;
}
}
When I display the grid, everything looks fine, but when the page is
postback and GridView_RowUpdating event occurs, I'm unable to find any
checkbox using GridView.Rows[e.RowIndex].FindControl method. I am able
only to find empty TableCells.
I have no more ideas how to solve this problem, please help me.
Thank you for your answer.
I have a reload_controls() method which is run in following cases:
Page_Load / !IsPostBack
GridView_RowEditing
GridView_RowCancelingEdit
reload_controls() consists code which read data from controls on page,
builds gridview (using template fields) and finally calls
GridView.DataBind(). If I try to run reload_controls() from OnInit, I
see an obvious error saying that controls are not instantiated.
Unfortunatelly I need to read from other controls to build gridview...
On 1 Wrz, 15:37, "Teemu Keiski" <jot...@aspalliance.comwrote:
Do you instantiate the template in every request? Best way to do it would be
in OnInit event of the Page.
--
Teemu Keiski
AspInsider, ASP.NET MVPhttp://blogs.aspadvice.com/jotekehttp://teemukeiski.net
<beton3...@gmail.comwrote in message
news:11********************@g4g2000hsf.googlegroup s.com...
Hello!
I'm building a GridView using code to add template fields, because
there is a random number of columns in result set from database. I'm
using a class with ITemplate interface for defining columns. I am
using a code which adds a checkbox for each column:
public void InstantiateIn(System.Web.UI.Control container)
{
switch (templateType)
{
case DataControlRowType.DataRow:
CheckBox cb = new CheckBox();
cb.Enabled = true;
cb.ID = columnName;
cb.DataBinding += new
EventHandler(this.CB_DataBinding);
container.Controls.Add(cb);
break;
default:
break;
}
}
When I display the grid, everything looks fine, but when the page is
postback and GridView_RowUpdating event occurs, I'm unable to find any
checkbox using GridView.Rows[e.RowIndex].FindControl method. I am able
only to find empty TableCells.
I have no more ideas how to solve this problem, please help me.- Ukryj cytowany tekst -
- Poka cytowany tekst -
Hi,
see: http://discuss.joelonsoftware.com/de...et.12.350266.2
--
Teemu Keiski
AspInsider, ASP.NET MVP http://blogs.aspadvice.com/joteke http://teemukeiski.net
<be*******@gmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
Thank you for your answer.
I have a reload_controls() method which is run in following cases:
Page_Load / !IsPostBack
GridView_RowEditing
GridView_RowCancelingEdit
reload_controls() consists code which read data from controls on page,
builds gridview (using template fields) and finally calls
GridView.DataBind(). If I try to run reload_controls() from OnInit, I
see an obvious error saying that controls are not instantiated.
Unfortunatelly I need to read from other controls to build gridview...
On 1 Wrz, 15:37, "Teemu Keiski" <jot...@aspalliance.comwrote:
>Do you instantiate the template in every request? Best way to do it would be in OnInit event of the Page.
-- Teemu Keiski AspInsider, ASP.NET MVPhttp://blogs.aspadvice.com/jotekehttp://teemukeiski.net
<beton3...@gmail.comwrote in message
news:11********************@g4g2000hsf.googlegrou ps.com...
Hello!
I'm building a GridView using code to add template fields, because
there is a random number of columns in result set from database. I'm
using a class with ITemplate interface for defining columns. I am
using a code which adds a checkbox for each column:
public void InstantiateIn(System.Web.UI.Control container)
{
switch (templateType)
{
case DataControlRowType.DataRow:
CheckBox cb = new CheckBox();
cb.Enabled = true;
cb.ID = columnName;
cb.DataBinding += new
EventHandler(this.CB_DataBinding);
container.Controls.Add(cb);
break;
default:
break;
}
}
When I display the grid, everything looks fine, but when the page is
postback and GridView_RowUpdating event occurs, I'm unable to find any
checkbox using GridView.Rows[e.RowIndex].FindControl method. I am able
only to find empty TableCells.
I have no more ideas how to solve this problem, please help me.- Ukryj
cytowany tekst -
- Poka cytowany tekst -
Thank you very much Teemu. This solution sounds very reasonable.
Unfortunately my time for this problem passed by and I decided not to
use GridView at all in this case... I will build custom table with
checkboxes.
On 2 Wrz, 09:04, "Teemu Keiski" <jot...@aspalliance.comwrote:
Hi,
see:http://discuss.joelonsoftware.com/de...et.12.350266.2
--
Teemu Keiski
AspInsider, ASP.NET MVPhttp://blogs.aspadvice.com/jotekehttp://teemukeiski.net
<beton3...@gmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
Thank you for your answer.
I have a reload_controls() method which is run in following cases:
Page_Load / !IsPostBack
GridView_RowEditing
GridView_RowCancelingEdit
reload_controls() consists code which read data from controls on page,
builds gridview (using template fields) and finally calls
GridView.DataBind(). If I try to run reload_controls() from OnInit, I
see an obvious error saying that controls are not instantiated.
Unfortunatelly I need to read from other controls to build gridview...
On 1 Wrz, 15:37, "Teemu Keiski" <jot...@aspalliance.comwrote:
Do you instantiate the template in every request? Best way to do it would
be
in OnInit event of the Page.
--
Teemu Keiski
AspInsider, ASP.NET
MVPhttp://blogs.aspadvice.com/jotekehttp://teemukeiski.net
<beton3...@gmail.comwrote in message
>news:11********************@g4g2000hsf.googlegrou ps.com...
Hello!
I'm building a GridView using code to add template fields, because
there is a random number of columns in result set from database. I'm
using a class with ITemplate interface for defining columns. I am
using a code which adds a checkbox for each column:
public void InstantiateIn(System.Web.UI.Control container)
{
switch (templateType)
{
case DataControlRowType.DataRow:
CheckBox cb = new CheckBox();
cb.Enabled = true;
cb.ID = columnName;
cb.DataBinding += new
EventHandler(this.CB_DataBinding);
container.Controls.Add(cb);
break;
default:
break;
}
}
When I display the grid, everything looks fine, but when the page is
postback and GridView_RowUpdating event occurs, I'm unable to find any
checkbox using GridView.Rows[e.RowIndex].FindControl method. I am able
only to find empty TableCells.
I have no more ideas how to solve this problem, please help me.- Ukryj
cytowany tekst -
- Poka cytowany tekst -- Ukryj cytowany tekst -
- Poka cytowany tekst -
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: NateDawg |
last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if
anyone has some input it would sure help me out.
Ok, I’ve noticed a few gridview problems floating around the forum....
|
by: Rob Roberts |
last post by:
Is there any way to add attributes to GridView ButtonFields? I'm looking
for a way to add event handlers to ButtonFields. With regular ASP.NET
buttons, I can add event handlers by using the...
|
by: JayD |
last post by:
I am using Visual Web Developer (vb.net) and have a gridview in a form. I can
update records using standard EDIT/UPDATE buttons. However, there are two
fields in every record (called ModifiedBy and...
|
by: Chicagoboy27 |
last post by:
I have dynamically bound a field to a gridview using the follwoing
code:
BoundField nameColumn = new BoundField();
nameColumn.DataField = "territory";
nameColumn.HeaderText = "Terr Num";...
|
by: Jeff |
last post by:
Hey
asp.net 2.0
In the source I posted below, there is a GridView (look at the bottom of the
script):
<asp:GridView ID="gvwOnline" runat="server">
</asp:GridView>
I'm trying to assign a...
|
by: Andrew Robinson |
last post by:
I am attempting to better automate a Pager Template within a GridView. I am
succesfully skinning a Drop Down List withing my control (the DDL is added
to my control). I correctly populate the item...
|
by: Mel |
last post by:
I have 10 columns total. 3 of them are invisible. The rest are read-
only BoundFields, 3 of which are editable fields using
TemplateFields. Upon editing, I want to validate what the user enters...
|
by: Craig Buchanan |
last post by:
I dynamically add data-bound templates to a gridview in my ascx control.
while this works correctly when the gridview is databound to the
datatable, i'm having issues on postback.
i would like...
|
by: Ahmedhussain |
last post by:
Hi there,
I m doing work on a gridview and Im getting an error:
A potentially dangerous Request.Form value was detected from the client (ctl00$Content$GridView1$ctl03$TextBox1="<span...
|
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: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
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: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
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: 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...
| | |