Hey Luke, I am trying to customize this.
I modified the coupon.ascx to display new field for category. I added the categories as the dropdownlist. Is there any better way to do this?
<asp:TemplateField headertext="<%$ Resources:Common,ApplyToCategory %>">
<EditItemTemplate>
<span class="sign"></span>
<asp:DropDownList id="categoryID" runat="server" Width="206px">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
protected void btnAdd_Click(object sender, EventArgs e)
{
mvwMain.SetActiveView(vwAdd);
dvwCoupon.ChangeMode(DetailsViewMode.Insert);
//getting all the categories
Category[] categories = Category.GetAll();
//storing the category ids and category names
string[] categoryIds = new string[categories.Length + 1];
string[] categoryNames = new string[categories.Length + 1];
//first element in the dropdown list should be empty
categoryIds[0] = "0";
categoryNames[0] = "Everything";
for (int i = 0; i < categories.Length; i++)
{
categoryIds[i + 1] = categories[i].CategoryId.ToString();
categoryNames[i + 1] = categories[i].Name;
}
//bind that string array to dropdownlist
categoryID.DataSource = categoryNames;
categoryID.DataBind();
}
This loads fine on the page but i need to change the edit coupon part too. When i go edit, its displaying the empty list. I don't know how to bind the list when someone is trying to edit the coupon and set the selected index from the database.
Can you please help?
Thanks
|