J
Jeff
Hey
ASP.NET 2.0
This is some of the markup of a UserControl I have in my project (consist of
a Repeater control and a ObjectDataSource):
<asp:Repeater ID="rptMessages" runat="server" DataSourceID="odsMessage"
OnItemDataBound="Display_Messages">
<HeaderTemplate><table width="100%"></HeaderTemplate>
<ItemTemplate>
<tr>
<td >
<div style="width:100%; height:100%; background-color:Lime;">
<div style="width:75px; height:75px; float:right;">
<asp:ImageButton ID="MemberPhoto" runat="server" Width="75px"
Height="75px" />
</div>
<asp:Label ID="lblHeader" runat="server" Text=""></asp:Label>
<asp:LinkButton ID="lbkLinkToMessage" runat="server"
OnCommand="Open_Message">Reply</asp:LinkButton>
<asp:Literal ID="ltMessage" runat="server"></asp:Literal>
</div>
</td>
</tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>
<asp:ObjectDataSource ID="odsMessage" runat="server"
SelectMethod="ExecuteMessage"
TypeName="AH.MyNetwork.BLL.Network.Message">
<SelectParameters>
<asprofileParameter Name="user" PropertyName="UserName"
Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
The repeater control displays items returned from the ObjectDataSource's
SelectMethod.
Each row in the Repeater control has a LinkButton:
<asp:LinkButton ID="lbkLinkToMessage" runat="server"
OnCommand="Open_Message">Reply</asp:LinkButton>
This is the method executed on the LinkButton's command event:
protected void Open_Message(Object sender, CommandEventArgs e)
{
int id = Convert.ToInt32(e.CommandArgument);
}
The goal is this: The Repeater control displays several rows, and when the
LinkButton in a row is clicked the UserControl "refreshes" (it changes from
displaying many rows to only display the row the user clicked on)
So when the LinkButton is clicked I want the UserControl to refresh
itself... In the LinkButton's command event (Open_Message) I've got the id
(id means here the value of a primary key in a table) of the row I want
displayed in the UserControl...
my PROBLEM is that I don't know how to "refresh" the UserControl. The only
thing I think about is to use the ObjectDataSource.Select method but I don't
know if executing the Select method the Repeater control also will "refresh"
itself:
protected void Open_Message(Object sender, CommandEventArgs e)
{
int id = Convert.ToInt32(e.CommandArgument);
odsMessage.SelectParameters.Add(new Parameter("Id", TypeCode.Int32,
id.ToString()));
odsMessage.Select();
}
Any suggestions?
Jeff
ASP.NET 2.0
This is some of the markup of a UserControl I have in my project (consist of
a Repeater control and a ObjectDataSource):
<asp:Repeater ID="rptMessages" runat="server" DataSourceID="odsMessage"
OnItemDataBound="Display_Messages">
<HeaderTemplate><table width="100%"></HeaderTemplate>
<ItemTemplate>
<tr>
<td >
<div style="width:100%; height:100%; background-color:Lime;">
<div style="width:75px; height:75px; float:right;">
<asp:ImageButton ID="MemberPhoto" runat="server" Width="75px"
Height="75px" />
</div>
<asp:Label ID="lblHeader" runat="server" Text=""></asp:Label>
<asp:LinkButton ID="lbkLinkToMessage" runat="server"
OnCommand="Open_Message">Reply</asp:LinkButton>
<asp:Literal ID="ltMessage" runat="server"></asp:Literal>
</div>
</td>
</tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>
<asp:ObjectDataSource ID="odsMessage" runat="server"
SelectMethod="ExecuteMessage"
TypeName="AH.MyNetwork.BLL.Network.Message">
<SelectParameters>
<asprofileParameter Name="user" PropertyName="UserName"
Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
The repeater control displays items returned from the ObjectDataSource's
SelectMethod.
Each row in the Repeater control has a LinkButton:
<asp:LinkButton ID="lbkLinkToMessage" runat="server"
OnCommand="Open_Message">Reply</asp:LinkButton>
This is the method executed on the LinkButton's command event:
protected void Open_Message(Object sender, CommandEventArgs e)
{
int id = Convert.ToInt32(e.CommandArgument);
}
The goal is this: The Repeater control displays several rows, and when the
LinkButton in a row is clicked the UserControl "refreshes" (it changes from
displaying many rows to only display the row the user clicked on)
So when the LinkButton is clicked I want the UserControl to refresh
itself... In the LinkButton's command event (Open_Message) I've got the id
(id means here the value of a primary key in a table) of the row I want
displayed in the UserControl...
my PROBLEM is that I don't know how to "refresh" the UserControl. The only
thing I think about is to use the ObjectDataSource.Select method but I don't
know if executing the Select method the Repeater control also will "refresh"
itself:
protected void Open_Message(Object sender, CommandEventArgs e)
{
int id = Convert.ToInt32(e.CommandArgument);
odsMessage.SelectParameters.Add(new Parameter("Id", TypeCode.Int32,
id.ToString()));
odsMessage.Select();
}
Any suggestions?
Jeff