Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Repeaters, Controls and Events

Reply
Thread Tools

Repeaters, Controls and Events

 
 
LandShark LandShark is offline
Junior Member
Join Date: Jul 2007
Location: Spokane WA for now
Posts: 1
 
      07-24-2007
Hi,

I am trying to use a REPEATER to display data. I have added a button to my item template. The data displays fine, and the buttons show as expected. The problem is events. I load and bind the repeater in the page_load function and so whenever I click a button the entire table goes away along with all its goodies. And if I set a breakpoint in the repeaters event handler it never seems to get called. I have read many posts but cant seem to find exactly what I need. From what I gather the repeater has a view stat that should persist if you create the repeater in the page_load function, and the event should fire if you are checking for postback in the page_load function before you databind on the repeater. Here is some code for insight.

protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
SqlConnection conx = new SqlConnection(@"Initial Catalog=ATC_Prod;Data Source=localhost;User ID=matt;Password=snoochie;timeout=10");
conx.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = new SqlCommand();

SqlParameter param1 = new SqlParameter();
SqlParameter param2 = new SqlParameter();
param1.ParameterName = "@customer";
param2.ParameterName = "@po";
param1.Value = DropDownList1.SelectedValue;
param2.Value = DropDownList2.SelectedValue;

da.SelectCommand.Parameters.Add(param1);
da.SelectCommand.Parameters.Add(param2);

da.SelectCommand.Connection = conx;
da.SelectCommand.CommandText = "Select distinct(PartNumber), count(PartNumber) from dbo.vw_order_statusAll WHERE Customer = @customer AND PO = @po GROUP BY PartNumber ORDER BY 1 DESC;";

da.Fill(ds, "vw_order_statusAll");
Repeater1.DataSource = ds.Tables[0];
Repeater1.DataBind();
}

AND MY REPEATER CODE:

<asp:Repeater id="Repeater1" OnItemCommand="Button_ItemCommand" runat="server">
<HeaderTemplate>
<table border="1">
<tr style="background: beige">
<th>Part Number</th>
<th>WO Qty</th>
<th>Get #'s</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background: white">
<td><%# DataBinder.Eval(Container.DataItem, "PARTNUMBER")%></td>
<td><%# DataBinder.Eval(Container.DataItem, "Column1")%></td>
<td><asp:Button CommandName="ID" Text = "WO Nums" runat="server" /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background: beige">
<td><%# DataBinder.Eval(Container.DataItem, "PARTNUMBER")%></td>
<td><%# DataBinder.Eval(Container.DataItem, "Column1")%></td>
<td><asp:Button CommandName="ID" Text = "WO Nums" runat="server" /></td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically adding controls with events (but events are not firing) SevDer ASP .Net 2 11-13-2007 06:33 AM
Linking events from controls, when the controls have been created =?Utf-8?B?cml2YWxAbmV3c2dyb3Vwcy5ub3NwYW0=?= ASP .Net 3 07-16-2007 04:02 PM
runtime events that generate other controls and events newbye ASP .Net 0 07-06-2006 06:27 PM
Events Events Events Please Help Chris ASP .Net Web Controls 0 08-30-2005 08:21 PM
Child controls in Composite Controls not firing events David Boike ASP .Net Web Controls 0 08-07-2003 05:39 PM



Advertisments