By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,218 Members | 1,236 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,218 IT Pros & Developers. It's quick & easy.

Help with finding datagrid and associating event

P: n/a
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_CurrentServicePlanProgramComma nd"

<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
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Also one more point, there are few grids on this page, but I need to
reference only this one

"News" <ge**@lycos.com> wrote in message
news:du********************@magma.ca...
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_CurrentServicePlanProgramComma nd"
> <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

Nov 18 '05 #2

P: n/a
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" <ge**@lycos.com> wrote in message
news:du********************@magma.ca...
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_CurrentServicePlanProgramComma nd"
> <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

Nov 18 '05 #3

P: n/a
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


"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ON*************@tk2msftngp13.phx.gbl...
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" <ge**@lycos.com> wrote in message
news:du********************@magma.ca...
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_CurrentServicePlanProgramComma nd"
>

<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


Nov 18 '05 #4

P: n/a
dgrdCurrentServicePlanPrograms.Items doesn't work ?????

Eliyahu

"News" <ge**@lycos.com> wrote in message
news:PK********************@magma.ca...
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


"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ON*************@tk2msftngp13.phx.gbl...
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" <ge**@lycos.com> wrote in message
news:du********************@magma.ca...
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_CurrentServicePlanProgramComma nd"
>
<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



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.