|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Is this posible?I have a 2 Repeaters in place on my WebForm.
What I would like to do is be able to select a record on the first repeater (contained within a ASP:Panel) to reveal the details of the record in the second Repeater (Contained in ASP:Panel2). What would I use to accomplish this? I am using stored procedures from SQL to facilitate the queries, I just can't seem to capture the selected item or ID of the record selected in the first repeater. Thank you for your thoughts. Sincerely, Tim You can put a button inside the repeater, then set it's CommandName="DoSomething".
Then handle the Repeater's ItemCommand event -- this is called when a button inside the repeater is clicked. You can make sure it's your button by checking the e.Item.CommandName == "DoSOmething" (this is the same as your CommandName specified above). So the problem is then to know what row you're working with, or more specifically, what's the primary key of your row in the DB that you should load into the other repeater. So in your Button, you can also fill in the CommandArgument in your ItemTemplate to data bind to the PK column from your database. This is presented to you in the ItemCommand event as e.Item.CommandArgument. This can then be used to populate your second Repeater. -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > I have a 2 Repeaters in place on my WebForm. > > What I would like to do is be able to select a record on the first > repeater (contained within a ASP:Panel) to reveal the details of the > record in the second Repeater (Contained in ASP:Panel2). > > What would I use to accomplish this? I am using stored procedures > from SQL to facilitate the queries, I just can't seem to capture the > selected item or ID of the record selected in the first repeater. > > Thank you for your thoughts. > > Sincerely, > > Tim > Brock,
Thank you very much for your time and thoughts. I am starting to understand a bit more but can't seem to get the command to fire. Here is my linkbutton control code: <asp:LinkButton Runat="server" ID="detail" CommandName="get_detail" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID")%>'> <%# DataBinder.Eval(Container.DataItem, "Cust_Name")%> </asp:LinkButton> Here is the code behind: private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { Summary.Fill(sum_hscti1); DataBind(); Panel1.Visible = true; Panel2.Visible = false; } } private void get_detail(object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { Panel1.Visible = false; Panel2.Visible = true; } The is placement of the Panel code in the IsPostBack the problem? Is the postback causing the Panel condition to reload first case instead of the case contained in the get_detail command? Thank you again for your time. Sincerely, Tim -- Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-web-controls/200505/1 Brock,
I have made some modifications that have resolved the Panel issue however, I am still confused on how to wire the linkbutton control in code behind so that the id value of the record is retained and used in the query to populate the second Panel. Here is my link button control code: <asp:LinkButton Runat="server" ID="detail" CommandName="get_detail" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID")%>'> <%# DataBinder.Eval(Container.DataItem, "Cust_Name")%> </asp:LinkButton> Here is my code behind: public void get_detail(object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { if (e.CommandName == "get_detail") { Panel1.Visible = false; Panel2.Visible = true; Full.Fill(full1); Comments.Fill(cmnts1); DataBind(); } } I know there is a whole section missing here that is needed to bind the id value of the control to the dataset for the second panel, but I can't decipher or locate any code examples to help me resolve this issue. Can you expand upon this for me please. Thank you for your time. Sincerely, Tim -- Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-web-controls/200505/1 Ok, so I have made some progress on this but have come to a barrier I can't
seem to get over. I can now get the variable result for the id chosen in the repeater but for some reason, I can't get the details of the summary record chosen. Here is my code behind: private void Repeater1_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { //Gets the value of the record chosen by the linkbutton int ID = Convert.ToInt32(e.CommandArgument); // Fills the dataset for geting the full details Full.Fill(full1); } Public void get_detail(object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { if (e.CommandName == "get_detail") { Panel1.Visible = false; Panel2.Visible = true; Comments.Fill(cmnts1); DataBind(); } } Can somone help me figure out the missing link (sorry, bad pun). Thank you. Tim -- Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-web-controls/200505/1
Dynamically Adding Controls
Utilities/Addon for Creating Tables Web Page Header and Menu User Controls Best free/cheap Menu Control for 1.1 Staggering Data using DataList, Repeater, etc... Repeater and RadioButton ASP.NET: MS Treeview loses data when posted to the server Dynamic load ascx control when DLL not in "/bin" Get state of Dynamically generated controls on post back |
|||||||||||||||||||||||