-- Merchant Brand Management
<Asp: gridView ID = "GridViewBrand" CellPadding = "0" CellSpacing = "1" runat = "server" AutoGenerateColumns = "False" GridLines = "None" Width = "98%" OnRowDataBound = "GridViewBrand_RowDataBound ">
<Columns>
<Asp: BoundField DataField = "BrandID" HeaderText = "no.">
<HeaderStyle CssClass = "gdv"/>
<ItemStyle HorizontalAlign = "Center" CssClass = "gdvRow2"/>
</Asp: BoundField>
<Asp: BoundField DataField = "BrandName" HeaderText = "brand name">
<HeaderStyle CssClass = "gdv"/>
<ItemStyle HorizontalAlign = "Center" CssClass = "gdvRow2"/>
</Asp: BoundField>
<Asp: BoundField DataField = "ManufacturerName" HeaderText = "manufacturer">
<HeaderStyle CssClass = "gdv"/>
<ItemStyle HorizontalAlign = "Center" CssClass = "gdvRow2"/>
</Asp: BoundField>
<Asp: TemplateField HeaderText = "add a brand to a seller">
<ItemTemplate>
<Asp: button ID = "btn_CreateDealerBrand" Text = "add this brand to sellers" DealerID = "0" BrandID = "0" runat = "server" OnClick = "CreateDealerBrand" CssClass = "istop1" onClientClick = "return confirm ('to join the brand? ') "/>
</ItemTemplate>
<HeaderStyle CssClass = "gdv"/>
<ItemStyle HorizontalAlign = "Center" CssClass = "gdvRow2"/>
</Asp: TemplateField>
</Columns>
</Asp: GridView>
Event background Code (Part ):
GridViewBrand_RowDataBound event (which can be defined in the property event of the gridview Control)
Protected void GridViewBrand_RowDataBound (object sender, GridViewRowEventArgs e)
{
If (e. Row. RowIndex> = 0)
{
String brandIDStr = e. Row. Cells [0]. Text;
String brandNameStr = Server. HtmlDecode (e. Row. Cells [1]. Text). ToString ();
Button btn_CreateDealerBrand = (Button) e. Row. Cells [3]. FindControl ("btn_CreateDealerBrand ");
Btn_CreateDealerBrand.Attributes ["BrandID"] = brandIDStr;
Btn_CreateDealerBrand.Attributes ["DealerID"] = dealer. DealerID. ToString ();
Btn_CreateDealerBrand.Text = "add brand to seller [" + dealer. UserName + "] [" + brandNameStr + "]";
Btn_CreateDealerBrand.OnClientClick = "return confirm ('add brand to seller [" + dealer. UserName + "] [" + brandNameStr + "]? ')";
}
}
CreateDealerBrand
Protected void CreateDealerBrand (object sender, EventArgs e)
{
// Permission: System Administrator and total Administrator
If (managerClient. ManagerType! = 1 & managerClient. ManagerType! = 2)
{
Response. Write ("Sorry! Contact the administrator. ");
Response. End ();
}
Button button = (Button) sender;
Home. Function. DealersBrand dealerBrand = new Home. Function. DealersBrand ();
DealerBrand. BrandID = int. Parse (button. Attributes ["BrandID"]. ToString ());
DealerBrand. DealerID = int. Parse (button. Attributes ["DealerID"]. ToString ());
DealerBrand. IsValid = 1;
DealerBrand. Create ();
If (dealerBrand. DealerBrandID = 0)
AlertMsg = "<script type = \" text/javascript \ "> alert (\" this seller already has this brand! \ "); </Script> ";
GridViewDatabind ();
GridView_DealerBrandDatabind ();
}