Repeaters, Controls and Events

Discussion in '.NET' started by LandShark, Jul 24, 2007.

  1. LandShark

    LandShark

    Joined:
    Jul 24, 2007
    Messages:
    1
    Location:
    Spokane WA for now
    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>
     
    LandShark, Jul 24, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmFtZXMgR2V1cnRz?=

    Bug with nested repeaters. Item events are called twice per item

    =?Utf-8?B?SmFtZXMgR2V1cnRz?=, Mar 15, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    977
    =?Utf-8?B?SmFtZXMgR2V1cnRz?=
    Mar 28, 2007
  2. MattB

    Controls in repeaters

    MattB, Jul 20, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    435
    MattB
    Jul 23, 2007
  3. schiavonir
    Replies:
    1
    Views:
    1,644
    schiavonir
    Mar 25, 2009
  4. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    409
    Chris
    Aug 30, 2005
  5. Axel

    Web User Controls in Repeaters with DataList

    Axel, Apr 20, 2010, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    1,463
Loading...

Share This Page