Imam dva dugmeta u jednoj stavci u repeateru . Kako pozvati dogadjaj za odredjeno dugme u jednoj stavci...
ASP.net
Code:
<asp:Repeater ID="repBrPorudzbi" runat="server"
DataSourceID="ods_SpisakPorudzbi" onitemdatabound="repBrPorudzbi_ItemDataBound"
onitemcommand="repBrPorudzbi_ItemCommand"
>
<ItemTemplate>
<div id="porudzbe" class="porudzbe">
<div id="BrPorudzbe" class="brojporudzbe">
<asp:Label ID="lblBrPorudzbe" runat="server" Text='<%# Eval("Sifra_Por") %> '/>
<asp:Button ID="btnDodajStavke" runat="server" CssClass="btnDodajStavke" Text="Prepravi/Dodaj stavke" CommandName="dodaj" />
<div><asp:ImageButton ID="imgPregledStampe" runat="server"
ImageUrl="~/GIF/Web_Printer.png" Height="27px" ImageAlign="Middle"
ToolTip="Pregled pre stampe!" Width="29px" CommandName="stampaj"/></div>
</div>
<div id="stavkePorudzbe" class="stavkeporudzbe" runat="server">
</div>
<hr size="1" />
<div id="ukupno" class="ukupno" runat="server">
</div>
</div>
</ItemTemplate>
</asp:Repeater>
<asp:Repeater ID="repBrPorudzbi" runat="server"
DataSourceID="ods_SpisakPorudzbi" onitemdatabound="repBrPorudzbi_ItemDataBound"
onitemcommand="repBrPorudzbi_ItemCommand"
>
<ItemTemplate>
<div id="porudzbe" class="porudzbe">
<div id="BrPorudzbe" class="brojporudzbe">
<asp:Label ID="lblBrPorudzbe" runat="server" Text='<%# Eval("Sifra_Por") %> '/>
<asp:Button ID="btnDodajStavke" runat="server" CssClass="btnDodajStavke" Text="Prepravi/Dodaj stavke" CommandName="dodaj" />
<div><asp:ImageButton ID="imgPregledStampe" runat="server"
ImageUrl="~/GIF/Web_Printer.png" Height="27px" ImageAlign="Middle"
ToolTip="Pregled pre stampe!" Width="29px" CommandName="stampaj"/></div>
</div>
<div id="stavkePorudzbe" class="stavkeporudzbe" runat="server">
</div>
<hr size="1" />
<div id="ukupno" class="ukupno" runat="server">
</div>
</div>
</ItemTemplate>
</asp:Repeater>
C# code
Code:
//Stampaj u HTML
private void stampa_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("StampaPorudzbe.aspx?brpo=" + lblBrPorudzbe2.Text);
}
//Dodaj ispravi porudzbu
private void btnDodaj_Click(object sender,EventArgs e)
{
Response.Redirect("Default.aspx");
}
protected void repBrPorudzbi_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "dodaj":
//dodavanje i prepravljanje stavki button
btnDodaj = (Button)e.Item.FindControl("btnDodajStavke");
btnDodaj.Click += new EventHandler(btnDodaj_Click);
break;
case "stampaj":
//stampa dugme (print button).
stampa = (ImageButton)e.Item.FindControl("imgPregledStampe");
stampa.Click += new ImageClickEventHandler(stampa_Click);
break;
default:
break;
}
//Stampaj u HTML
private void stampa_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("StampaPorudzbe.aspx?brpo=" + lblBrPorudzbe2.Text);
}
//Dodaj ispravi porudzbu
private void btnDodaj_Click(object sender,EventArgs e)
{
Response.Redirect("Default.aspx");
}
protected void repBrPorudzbi_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "dodaj":
//dodavanje i prepravljanje stavki button
btnDodaj = (Button)e.Item.FindControl("btnDodajStavke");
btnDodaj.Click += new EventHandler(btnDodaj_Click);
break;
case "stampaj":
//stampa dugme (print button).
stampa = (ImageButton)e.Item.FindControl("imgPregledStampe");
stampa.Click += new ImageClickEventHandler(stampa_Click);
break;
default:
break;
}
....