Help with finding datagrid and associating event

N

News

I have a page with many controls. Among these controls there is a table
which is a datagrid with nested repeater inside. My problem is that I can
not use DataGridCommandEventArgs to get datagrid elements because submit
button is not in datagrid and uses onClick event btnSaveServicePlanUpdate.


Here is the code:

Sub btnSaveServicePlanUpdate_OnClick(sender As Object, e As EventArgs)
' need to get the key value serviceplanprogram_id and other elements of
datagrid here
.....
Response.Write("<br>Program id: " & intProgramID)
Response.Write("<br>Notes: " & Request.Form("txtNotes"))
.....
End Sub


<asp:table id="tClientNote" runat="server" CellPadding="3" CellSpacing="0">
<asp:tablerow runat="server">
<asp:tablecell runat="server">
.....
<asp:tablerow runat="server">
<asp:tablecell runat="server">Notes</asp:tablecell>
<asp:tablecell runat="server"><ASP:TextBox id="txtNotes" runat="server"
Text="" TextMode="Multiline" Columns="40" Rows="4" /></asp:tablecell>
</asp:tablerow>
<asp:tablerow runat="server">
<asp:tablecell runat="server">Added By</asp:tablecell>
<asp:tablecell runat="server"><asp:label id="lblAdded_by" Text=""
runat="server" /></asp:tablecell>
</asp:tablerow>
....
<asp:tablerow runat="server">
<asp:tablecell columnspan="2" runat="server">
<ASP:DataGrid id="dgrdCurrentServicePlanPrograms" RunAt="Server"
Width="800" BorderWidth="0" CellPadding="3" CellSpacing="0"
HeaderStyle-BackColor="#F6F6F6"
AlternatingItemStyle-BackColor="AliceBlue"
AutoGenerateColumns="False" DataKeyField="serviceplanprogram_id"
AllowPaging="False"
OnItemCommand="Grid_CurrentServicePlanProgramCommand"<ItemStyle VerticalAlign="top" />
<Columns>
<asp:BoundColumn Visible="False" HeaderText=""
DataField="serviceplanprogram_id" />
<asp:BoundColumn HeaderText="Program" DataField="program_name" />
<asp:TemplateColumn HeaderText="Notes">
<ItemTemplate>
<ASP:TextBox id="txtActivityNotes" runat="server" Text=""
TextMode="Multiline" columns="15" rows="3" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn ItemStyle-Width="20%" HeaderText="Current
progress toward goals<br />(1 lowest, 3 highest)">
<ItemTemplate>
<asp:dropdownlist id="ddlCurrent_progress" CssClass="required"
runat="server">
<asp:listitem text="(unspecified)" value="-1" runat="server" />
<asp:listitem text="1" value="1" runat="server" />
<asp:listitem text="2" value="2" runat="server" />
<asp:listitem text="3" value="3" runat="server" />
</asp:dropdownlist>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Comments">
<ItemTemplate>
<ASP:Repeater id="rptActivities"
DataSource='<%# GetActivities( Container.DataItem("program_id") )
%>'
runat="server">
<ItemTemplate>
<table border="0">
<tr>
<td width="70%">
<ASP:CheckBox id="chkActivityID" Value='<%#
Container.DataItem("activity_id") %>' runat="server" Text='<%#
Container.DataItem("name") %>' />
</td>
<td width="30%">
<ASP:TextBox id="txtActivity_other" visible='<%#
ShowOther(Container.DataItem("is_allow_additional_text")) %>'
maxlenght="100" runat="server" columnspan="10" />
</td>
</table>
</ItemTemplate>
</ASP:Repeater>
</ItemTemplate>
</asp:TemplateColumn>



</Columns>
</ASP:DataGrid>
</asp:tablecell>
</asp:tablerow>

<asp:tablerow runat="server">
<asp:tablecell columnspan="2" runat="server" HorizontalAlign="center"
runat="server">
<asp:button id="btnSaveServicePlanUpdate" Text="Save" Visible="true"
runat="server" CommandName="saveupdate"
OnClick="btnSaveServicePlanUpdate_OnClick" />
</asp:tablecell>
</asp:tablerow>











.....
Thanks
 
N

News

Also one more point, there are few grids on this page, but I need to
reference only this one



News said:
I have a page with many controls. Among these controls there is a table
which is a datagrid with nested repeater inside. My problem is that I can
not use DataGridCommandEventArgs to get datagrid elements because submit
button is not in datagrid and uses onClick event btnSaveServicePlanUpdate.


Here is the code:

Sub btnSaveServicePlanUpdate_OnClick(sender As Object, e As EventArgs)
' need to get the key value serviceplanprogram_id and other elements of
datagrid here
....
Response.Write("<br>Program id: " & intProgramID)
Response.Write("<br>Notes: " & Request.Form("txtNotes"))
....
End Sub


<asp:table id="tClientNote" runat="server" CellPadding="3" CellSpacing="0">
<asp:tablerow runat="server">
<asp:tablecell runat="server">
....
<asp:tablerow runat="server">
<asp:tablecell runat="server">Notes</asp:tablecell>
<asp:tablecell runat="server"><ASP:TextBox id="txtNotes" runat="server"
Text="" TextMode="Multiline" Columns="40" Rows="4" /></asp:tablecell>
</asp:tablerow>
<asp:tablerow runat="server">
<asp:tablecell runat="server">Added By</asp:tablecell>
<asp:tablecell runat="server"><asp:label id="lblAdded_by" Text=""
runat="server" /></asp:tablecell>
</asp:tablerow>
...
<asp:tablerow runat="server">
<asp:tablecell columnspan="2" runat="server">
<ASP:DataGrid id="dgrdCurrentServicePlanPrograms" RunAt="Server"
Width="800" BorderWidth="0" CellPadding="3" CellSpacing="0"
HeaderStyle-BackColor="#F6F6F6"
AlternatingItemStyle-BackColor="AliceBlue"
AutoGenerateColumns="False" DataKeyField="serviceplanprogram_id"
AllowPaging="False"
OnItemCommand="Grid_CurrentServicePlanProgramCommand"
<ItemStyle VerticalAlign="top" />
<Columns>
<asp:BoundColumn Visible="False" HeaderText=""
DataField="serviceplanprogram_id" />
<asp:BoundColumn HeaderText="Program" DataField="program_name" />
<asp:TemplateColumn HeaderText="Notes">
<ItemTemplate>
<ASP:TextBox id="txtActivityNotes" runat="server" Text=""
TextMode="Multiline" columns="15" rows="3" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn ItemStyle-Width="20%" HeaderText="Current
progress toward goals<br />(1 lowest, 3 highest)">
<ItemTemplate>
<asp:dropdownlist id="ddlCurrent_progress" CssClass="required"
runat="server">
<asp:listitem text="(unspecified)" value="-1" runat="server" />
<asp:listitem text="1" value="1" runat="server" />
<asp:listitem text="2" value="2" runat="server" />
<asp:listitem text="3" value="3" runat="server" />
</asp:dropdownlist>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Comments">
<ItemTemplate>
<ASP:Repeater id="rptActivities"
DataSource='<%# GetActivities(
Container.DataItem("program_id") )
 
E

Eliyahu Goldin

May be I didn't get the problem right. If you know the datagrid name, why
can't you navigate it in the button's OnClick event handler using all
available datagrid members, like SelectrdItem, SelectedIndex?

Eliyahu

News said:
I have a page with many controls. Among these controls there is a table
which is a datagrid with nested repeater inside. My problem is that I can
not use DataGridCommandEventArgs to get datagrid elements because submit
button is not in datagrid and uses onClick event btnSaveServicePlanUpdate.


Here is the code:

Sub btnSaveServicePlanUpdate_OnClick(sender As Object, e As EventArgs)
' need to get the key value serviceplanprogram_id and other elements of
datagrid here
....
Response.Write("<br>Program id: " & intProgramID)
Response.Write("<br>Notes: " & Request.Form("txtNotes"))
....
End Sub


<asp:table id="tClientNote" runat="server" CellPadding="3" CellSpacing="0">
<asp:tablerow runat="server">
<asp:tablecell runat="server">
....
<asp:tablerow runat="server">
<asp:tablecell runat="server">Notes</asp:tablecell>
<asp:tablecell runat="server"><ASP:TextBox id="txtNotes" runat="server"
Text="" TextMode="Multiline" Columns="40" Rows="4" /></asp:tablecell>
</asp:tablerow>
<asp:tablerow runat="server">
<asp:tablecell runat="server">Added By</asp:tablecell>
<asp:tablecell runat="server"><asp:label id="lblAdded_by" Text=""
runat="server" /></asp:tablecell>
</asp:tablerow>
...
<asp:tablerow runat="server">
<asp:tablecell columnspan="2" runat="server">
<ASP:DataGrid id="dgrdCurrentServicePlanPrograms" RunAt="Server"
Width="800" BorderWidth="0" CellPadding="3" CellSpacing="0"
HeaderStyle-BackColor="#F6F6F6"
AlternatingItemStyle-BackColor="AliceBlue"
AutoGenerateColumns="False" DataKeyField="serviceplanprogram_id"
AllowPaging="False"
OnItemCommand="Grid_CurrentServicePlanProgramCommand"
<ItemStyle VerticalAlign="top" />
<Columns>
<asp:BoundColumn Visible="False" HeaderText=""
DataField="serviceplanprogram_id" />
<asp:BoundColumn HeaderText="Program" DataField="program_name" />
<asp:TemplateColumn HeaderText="Notes">
<ItemTemplate>
<ASP:TextBox id="txtActivityNotes" runat="server" Text=""
TextMode="Multiline" columns="15" rows="3" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn ItemStyle-Width="20%" HeaderText="Current
progress toward goals<br />(1 lowest, 3 highest)">
<ItemTemplate>
<asp:dropdownlist id="ddlCurrent_progress" CssClass="required"
runat="server">
<asp:listitem text="(unspecified)" value="-1" runat="server" />
<asp:listitem text="1" value="1" runat="server" />
<asp:listitem text="2" value="2" runat="server" />
<asp:listitem text="3" value="3" runat="server" />
</asp:dropdownlist>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Comments">
<ItemTemplate>
<ASP:Repeater id="rptActivities"
DataSource='<%# GetActivities(
Container.DataItem("program_id") )
 
N

News

Yes, I know the name but I can not find a way to directly reference it.
I am sure this is more simple than I have come up with, I did it this way:

Dim dgItem As DataGridItem

For Each rptItem In oRepeater.Items
intProgramID = dgItem.Cells(0).Text
....

Next
 

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,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top