How to determing Grid object

T

tshad

I have multiple Grid objects that are editable on my page. The following is
an example of the onEditCommand method. In this case D1 (the Grid object)
is known.

****************************************************
sub DataEdit(S as Object, E as DataGridCommandEventArgs)
trace.warn("in DataEdit")
D1.EditItemIndex=Cint(E.Item.ItemIndex)
FillUpGrid()
end sub
*****************************************************

In my case, I have a Datalist that has multiple DataGrids in them, something
like:

************************************************************
<asp:datalist id="DataList1"
runat="server"
Width="100%"
BorderWidth="0px"
OnItemCommand="OnSelectIndexChanged"
footerstyle-horizontalalign="center"
CellPadding="0"
CellSpacing="0"
style="margin:0">
<AlternatingItemStyle cssClass=alternateRow
</AlternatingItemStyle>
<asp:DataGrid visible="False"
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateColumns="False"
GridLines="None"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
</asp:datalist>
******************************************************************************************

Here there are multiple datagrids (one for each listitem). When I run my
onEditCommand routine, it needs to know the DataGrid to bind the data to.

It can't be DataGrid1.

How do I determine the Grid object from:

sub DataEdit(S as Object, E as DataGridCommandEventArgs)

Thanks,

Tom.
 
S

Scott Mitchell [MVP]

Tom, typically you'd have a separate event handler for each of the
DataGrids' OnEditCommand events. However, you have some (or all) of the
DataGrid's trigger the same event handler. The first input parameter of
the event handler contains the control that raised the event.

sub DataEdit(S as Object, E as DataGridCommandEventArgs)
trace.warn("in DataEdit")

Dim dg as DataGrid = CType(S, DataGrid)
trace.warn("The DataGrid is " & dg.ID)

D1.EditItemIndex=Cint(E.Item.ItemIndex)
FillUpGrid()
end sub

hth

I have multiple Grid objects that are editable on my page. The following is
an example of the onEditCommand method. In this case D1 (the Grid object)
is known.

****************************************************
sub DataEdit(S as Object, E as DataGridCommandEventArgs)
trace.warn("in DataEdit")
D1.EditItemIndex=Cint(E.Item.ItemIndex)
FillUpGrid()
end sub
*****************************************************

In my case, I have a Datalist that has multiple DataGrids in them, something
like:

************************************************************
<asp:datalist id="DataList1"
runat="server"
Width="100%"
BorderWidth="0px"
OnItemCommand="OnSelectIndexChanged"
footerstyle-horizontalalign="center"
CellPadding="0"
CellSpacing="0"
style="margin:0">
<AlternatingItemStyle cssClass=alternateRow
<asp:DataGrid visible="False"
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateColumns="False"
GridLines="None"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
</asp:datalist>
******************************************************************************************

Here there are multiple datagrids (one for each listitem). When I run my
onEditCommand routine, it needs to know the DataGrid to bind the data to.

It can't be DataGrid1.

How do I determine the Grid object from:

sub DataEdit(S as Object, E as DataGridCommandEventArgs)

Thanks,

Tom.


--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
T

tshad

Scott,

That was what I was looking for.

I assume that I would then do something like:

Dim dg as DataGrid = CType(S, DataGrid)

dg.bind()

I really appreciate the help,

Thanks,

Tom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top