an ASP.NET Open Source CMS & eCommerce platform
Search:
Skip Navigation LinksHome > DotShoppingCart Forums > Support > Using DotShoppingCart > adding a new tab to the product edit page
Last Post 2/18/2010 1:49:54 PM By bansal_db. 5 replies.
2/16/2010 7:03:34 AM
bansal_db
Posts: 181
Joined: 4/13/2009
adding a new tab to the product edit page
I added a new tab to the product edit page which shows a grid view, but the data is not showing up in the gridview. When i try storing the data from gridview in temp variables, the data is there but the gridview shows up with empty rows. It shows the exact number of rows that the result set has every time but they are blank.
 
I added this to the productEdit page for both Item Template and Edit Item Template.
 
<ajaxc:TabPanel id="tabCustomDiscount" runat="server" headertext="Custom Discount">
                        <ContentTemplate>
                            <dsc:ProductCustomDiscount id="productCustomDiscountView" runat="server" />
                        </ContentTemplate>
                    </ajaxc:TabPanel>
 
 
In the ProductCustomDiscount.ascx i have a gridview
 
<asp:GridView ID="discountView" AutoGenerateColumns="False"
    runat="server" showrownumber="true" Width="421px" EmptyDataText="No Data"
    Height="102px">
      <Columns>
     <asp:TemplateField HeaderText="Role">
                    <EditItemTemplate>
                        <asp:Label ID="role" runat="server"></asp:Label>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="role" runat="server" Width="150"></asp:Label>
                    </ItemTemplate>
       </asp:TemplateField>
       <asp:TemplateField headertext="<%$ Resources:Common,Discount %>" itemstyle-width="150px">
                <EditItemTemplate>
                        <asp:TextBox ID="discount" runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:TextBox ID="discount" runat="server" Width="200"></asp:TextBox>
                    </ItemTemplate>
<ItemStyle Width="180px"></ItemStyle>
            </asp:TemplateField>
       </Columns>
     </asp:GridView>
 
 
and in ProductCustomDiscount.ascx.cs i am filling this gridview
 
customDiscount cs = new customDiscount();
        discountView = cs.getProductDiscounts(Utils.GetIntParameter("pid", 0), discountView);
 
for (int i = 0; i < discountView.Rows.Count; i++)
        {
            GridViewRow row = discountView.Rows[i];
            temp = ((Label)row.FindControl("role")).Text;
            temp2 = ((TextBox)row.FindControl("discount")).Text;
        }
 
temp and temp2 stores the right data. But it doesn't display in the gridview. GridView always shows blank rows. I moved the gridview to some other page and it showed up fine.
So i am guessing i have to do something more in the product edit page. Not sure what. Can you please help?
 
Thanks

 
 
2/16/2010 4:24:01 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: adding a new tab to the product edit page
Where is your databinding code? Make sure you have databind working correctly.
DotShoppingCart Staff
2/17/2010 8:21:37 AM
bansal_db
Posts: 181
Joined: 4/13/2009
Re: adding a new tab to the product edit page
Here is the databinding code. The data is getting binded to the gridview because i tried copying the gridview to some other page and all the code behind method to get the data....it loaded up fine and displayed everything. Its only on the product edit that its not displaying the data. Just blank rows.
 
 public GridView getProductDiscounts(int productId, GridView discounts)
    {
DataSet ds = new DataSet();
        ds.Tables.Add("Table");
        DiscountsDataContext db = new DiscountsDataContext(ConfigurationController.SiteConfigurationController.GetSiteConnectionString(SiteNavigation.GetHost()));
        var cUse = from cd in db.DSC_CustomDiscounts
                   from r in db.DSC_Roles
                   from p in db.DSC_Products
                   where cd.productId == productId && cd.productId == p.productId && r.roleId == cd.roleId
                   select cd;

        int count = cUse.Count();
        for (int i = 0; i < count; i++)
        {
            DataRow dr = ds.Tables[0].NewRow();
            ds.Tables[0].Rows.Add(dr);
            discounts.DataSource = ds;
            discounts.DataBind();
        }
        customDiscount cs = new customDiscount();
        string[] role = new string[count];
        decimal[] discount = new decimal[count];
        int loop = 0;
        foreach (var x in cUse)
        {
            role[loop] = x.DSC_Role.name;
            discount[loop] = x.discountRate;
            loop++;
        }

        for (int i = 0; i < count; i++)
        {
            GridViewRow row = discounts.Rows[i];
            ((Label)row.FindControl("role")).Text = role[i];
            ((TextBox)row.FindControl("discount")).Text = discount[i].ToString();
        }
        return discounts;
}
2/18/2010 10:06:35 AM
bansal_db
Posts: 181
Joined: 4/13/2009
Re: adding a new tab to the product edit page
Luke anything on this?
2/18/2010 1:30:31 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: adding a new tab to the product edit page
You probably want to move the following code out of the loop.
 
discounts.DataSource = ds;
discounts.DataBind();
 
How does getProductDiscounts get called? You want to put it inside the following OnDataBinding code. 
 
    protected override void OnDataBinding(EventArgs e) {
        base.OnDataBinding(e);
        
    }
DotShoppingCart Staff
2/18/2010 1:49:54 PM
bansal_db
Posts: 181
Joined: 4/13/2009
Re: adding a new tab to the product edit page
i moved the getProductDiscounts inside the OnDataBinding code from PageLoad, but i still get the empty gridview. I also moved the other two lines outside the loop.
 
protected override void OnDataBinding(EventArgs e) {
        base.OnDataBinding(e);
        discountView = cs.getProductDiscounts(Utils.GetIntParameter("pid", 0), discountView);
    }
 
 
This is the gridview i get. The number of rows is exactly equal to the number of roles but the data is not displaying. It does show up if i move the gridview to some other page. I am having problem displaying on the product edit page.
 
<img src="https://www.sd9000.com/dbfile.axd?name=1.jpg" alt="" />