473,385 Members | 1,587 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,385 software developers and data experts.

Dynamic Datagrid

Hi,

I have a page that has a datagrid bound to a dataset. Items are added to
the dataset at particular times (ie the click event of an item in a tree
control) then bound to the grid. The grid has an image button in a Template
column that is used to remove an item (dataset row). I can't re-bind the
grid on the postback or I lose the event handler for the button. I also have
a column that contains a textbox that I need to handle the TextChanged event,
but because of not being able to bind on the postback, I lose the binding to
the grid before I get to the event handler. How can I either prevent or work
around this?

--
Thanks
Nov 19 '05 #1
4 1374
Maybe I can simplify my explanation.

I need to capture the value entered into the textbox when the user changes
it, but if the grid isn't re-bound on the postback, the textbox that my
quantity is entered into doesn't exist and I can't handle the event. On the
other hand, if I do re-bind on the postback, I loose the event handler for
the remove button.

Currently, I handle the remove button click (it's an image button in a
template column of the grid) in the ItemCommand event of the grid. Can I
handle the button as I would a regular button (ie. capture the click event
instead of the itemcommand event) or would that event handler be wiped out
just the same because it's within the grid? I'll try to code this, but if
someone can shed some light on this so I don't stray too far down the wrong
path, I'd appreciate it.

Thanks.

"mwhalen" wrote:
Hi,

I have a page that has a datagrid bound to a dataset. Items are added to
the dataset at particular times (ie the click event of an item in a tree
control) then bound to the grid. The grid has an image button in a Template
column that is used to remove an item (dataset row). I can't re-bind the
grid on the postback or I lose the event handler for the button. I also have
a column that contains a textbox that I need to handle the TextChanged event,
but because of not being able to bind on the postback, I lose the binding to
the grid before I get to the event handler. How can I either prevent or work
around this?

--
Thanks

Nov 19 '05 #2
Why if you rebind data source you will loose the event
handler for the remove button?

Elton Wang
el********@hotmail.com
-----Original Message-----
Maybe I can simplify my explanation.

I need to capture the value entered into the textbox when the user changesit, but if the grid isn't re-bound on the postback, the textbox that myquantity is entered into doesn't exist and I can't handle the event. On theother hand, if I do re-bind on the postback, I loose the event handler forthe remove button.

Currently, I handle the remove button click (it's an image button in atemplate column of the grid) in the ItemCommand event of the grid. Can Ihandle the button as I would a regular button (ie. capture the click eventinstead of the itemcommand event) or would that event handler be wiped outjust the same because it's within the grid? I'll try to code this, but ifsomeone can shed some light on this so I don't stray too far down the wrongpath, I'd appreciate it.

Thanks.

"mwhalen" wrote:
Hi,

I have a page that has a datagrid bound to a dataset. Items are added to the dataset at particular times (ie the click event of an item in a tree control) then bound to the grid. The grid has an image button in a Template column that is used to remove an item (dataset row). I can't re-bind the grid on the postback or I lose the event handler for the button. I also have a column that contains a textbox that I need to handle the TextChanged event, but because of not being able to bind on the postback, I lose the binding to the grid before I get to the event handler. How can I either prevent or work around this?

--
Thanks

.

Nov 19 '05 #3
hi mwhalen,

What you need to do is add your remove button when the row is added (and
also add the event handlers and such for the button) and handle the click
event of the button instead of using the ItemCommand event of the datagrid.
Your click event handler will not be lost if you operate it this way.

Thanks,
mwhalen

"mwhalen" wrote:
Maybe I can simplify my explanation.

I need to capture the value entered into the textbox when the user changes
it, but if the grid isn't re-bound on the postback, the textbox that my
quantity is entered into doesn't exist and I can't handle the event. On the
other hand, if I do re-bind on the postback, I loose the event handler for
the remove button.

Currently, I handle the remove button click (it's an image button in a
template column of the grid) in the ItemCommand event of the grid. Can I
handle the button as I would a regular button (ie. capture the click event
instead of the itemcommand event) or would that event handler be wiped out
just the same because it's within the grid? I'll try to code this, but if
someone can shed some light on this so I don't stray too far down the wrong
path, I'd appreciate it.

Thanks.

"mwhalen" wrote:
Hi,

I have a page that has a datagrid bound to a dataset. Items are added to
the dataset at particular times (ie the click event of an item in a tree
control) then bound to the grid. The grid has an image button in a Template
column that is used to remove an item (dataset row). I can't re-bind the
grid on the postback or I lose the event handler for the button. I also have
a column that contains a textbox that I need to handle the TextChanged event,
but because of not being able to bind on the postback, I lose the binding to
the grid before I get to the event handler. How can I either prevent or work
around this?

--
Thanks

Nov 19 '05 #4
http://aspnet.4guysfromrolla.com/articles/042402-1.aspx - near the bottom of
the article - Re-binding the grid flushes out the ItemCommand event. This
was causing a problem because I build the grid dynamically and I have to
re-bind the dataset to the grid on the postback.

I have things working the way I need them too now.

Thanks.

"Elton Wang" wrote:
Why if you rebind data source you will loose the event
handler for the remove button?

Elton Wang
el********@hotmail.com
-----Original Message-----
Maybe I can simplify my explanation.

I need to capture the value entered into the textbox when

the user changes
it, but if the grid isn't re-bound on the postback, the

textbox that my
quantity is entered into doesn't exist and I can't handle

the event. On the
other hand, if I do re-bind on the postback, I loose the

event handler for
the remove button.

Currently, I handle the remove button click (it's an

image button in a
template column of the grid) in the ItemCommand event of

the grid. Can I
handle the button as I would a regular button (ie.

capture the click event
instead of the itemcommand event) or would that event

handler be wiped out
just the same because it's within the grid? I'll try to

code this, but if
someone can shed some light on this so I don't stray too

far down the wrong
path, I'd appreciate it.

Thanks.

"mwhalen" wrote:
Hi,

I have a page that has a datagrid bound to a dataset. Items are added to the dataset at particular times (ie the click event of an item in a tree control) then bound to the grid. The grid has an image button in a Template column that is used to remove an item (dataset row). I can't re-bind the grid on the postback or I lose the event handler for the button. I also have a column that contains a textbox that I need to handle the TextChanged event, but because of not being able to bind on the postback, I lose the binding to the grid before I get to the event handler. How can I either prevent or work around this?

--
Thanks

.

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
0
by: JP011 | last post by:
Hello I have hit a major road block when it comes to building my dynamic datagrid. To make a long story short I need a dynamic datagrid because my connection string could change and I need the...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
0
by: optimizeit | last post by:
What I am attempting to do is import an Excel Workbook and display the worksheets in a datagrid dynamically. I am very close to getting this to work. I have to this point successfully imported a...
0
by: tafpin | last post by:
I have an application with a datagrid. In the IDE I have 2 template columns. The first has an image button and the second contains a link button. According to the results that I get back I must...
1
by: benoit | last post by:
Hi, I created a Dynamic Datagrid and i added an EditCommandColumn to it. Works fine, but my Editcommand eventhandler seems to have a problem with PostBack This is my code private DataGrid...
7
by: CanoeGuy | last post by:
I have been trying for the last two weeks to display a dynamic DataGrid. The data that I'm pulling from a SQL Server DB will have whole columns that will be either NULL or 0. I want to display...
4
by: tg | last post by:
Visual Studio 2003 My problem is that I am dynamically creating a datagrid on pageload. The datagrid is completely dynamic as it is based on the number of columns returned from a recordset. The...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
0
by: KA NMC | last post by:
I have a dataGrid that is populated by SQL table. The Datagrid has two dynamic columns - that I created to for calculations. I want to sort the grid on frmload by one of the dynamic columns is that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.