New field in database table
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
New field in database table
I'm adding a new field to the ac_ShipMethods table and am trying to get it to display in the admin where you view the shipmethods. Here is what I have so far. It doesn't break the page, but it doesn't do anything either.
How can I get it to show the value in the table for each ShipMethodID? I knew how to do it in 5.5, but it's more complicated in 7 - at least to me it is,working around the .net display controls.
//w2m jme 120408 add indicator for special shipping restrictions
private int _Indicator;
public int Indicator
{
get { return _Indicator; }
}
protected void GetIndicator(int shipMethodId)
{
Microsoft.Practices.EnterpriseLibrary.Data.Database database = Token.Instance.Database;
//GET THE CURRENT W2M INDICATOR FOR THAT SHIPPING METHOD
DbCommand selectCommand = database.GetSqlStringCommand("SELECT w2m_Indicator FROM ac_ShipMethods WHERE ShipMethodId = @shipMethodId");
database.AddInParameter(selectCommand, "@shipMethodId", DbType.Int32, shipMethodId);
int Indicator = (int)database.ExecuteScalar(selectCommand);
//set default value of 1
if (Indicator == null) Indicator = 1;
}
Thanks
How can I get it to show the value in the table for each ShipMethodID? I knew how to do it in 5.5, but it's more complicated in 7 - at least to me it is,working around the .net display controls.
//w2m jme 120408 add indicator for special shipping restrictions
private int _Indicator;
public int Indicator
{
get { return _Indicator; }
}
protected void GetIndicator(int shipMethodId)
{
Microsoft.Practices.EnterpriseLibrary.Data.Database database = Token.Instance.Database;
//GET THE CURRENT W2M INDICATOR FOR THAT SHIPPING METHOD
DbCommand selectCommand = database.GetSqlStringCommand("SELECT w2m_Indicator FROM ac_ShipMethods WHERE ShipMethodId = @shipMethodId");
database.AddInParameter(selectCommand, "@shipMethodId", DbType.Int32, shipMethodId);
int Indicator = (int)database.ExecuteScalar(selectCommand);
//set default value of 1
if (Indicator == null) Indicator = 1;
}
Thanks
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: New field in database table
Are you modifying /Admin/Shipping/Methods/Default.aspx?
Nick Cole
http://www.ethofy.com
http://www.ethofy.com
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: New field in database table
Yes, I was trying. I gave up and went to each edit shipmeth page in admin where the other changes are made, which I would have had to do anyway to edit the custom field. I've got that working, but it would be nice to display the new field on the Default.aspx.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: New field in database table
The problem seems to be in the GetIndicator method try following code
Code: Select all
protected void GetIndicator(int shipMethodId)
{
Microsoft.Practices.EnterpriseLibrary.Data.Database database = Token.Instance.Database;
//GET THE CURRENT W2M INDICATOR FOR THAT SHIPPING METHOD
DbCommand selectCommand = database.GetSqlStringCommand("SELECT w2m_Indicator FROM ac_ShipMethods WHERE ShipMethodId = @shipMethodId");
database.AddInParameter(selectCommand, "@shipMethodId", DbType.Int32, shipMethodId);
int indicator = (int)database.ExecuteScalar(selectCommand);
//set default value of 1
if (indicator == null) indicator = 1;
_Indicator = indicator;
}
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: New field in database table
How would I put that into a new field added to the Gridview? I don't think it's part of the dataitem?
I've tried all kinds of variations of this: _indicator, Indicator, indicator Eval = etc.
<asp:TemplateField HeaderText="Ind">
<ItemTemplate>
<% =Indicator %>
</ItemTemplate>
</asp:TemplateField>
I've tried all kinds of variations of this: _indicator, Indicator, indicator Eval = etc.
<asp:TemplateField HeaderText="Ind">
<ItemTemplate>
<% =Indicator %>
</ItemTemplate>
</asp:TemplateField>
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: New field in database table
Mazhar, on your code I get an invalid cast and debugger shows
Warning 5 The result of the expression is always 'false' since a value of type 'int' is never equal to 'null' of type 'int?'
Warning 5 The result of the expression is always 'false' since a value of type 'int' is never equal to 'null' of type 'int?'
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: New field in database table
oops! It seems that its due to following codeMazhar, on your code I get an invalid cast and debugger shows
Warning 5 The result of the expression is always 'false' since a value of type 'int' is never equal to 'null' of type 'int?'
Just replace this part of code with something like//set default value of 1
if (indicator == null) indicator = 1;
Code: Select all
//set default value of 1
if (indicator == 0) indicator = 1;
Re: New field in database table
Yes its not the part of dataitem. Better you change the return type of your GetIndicator function to int and return the indicator value. Then you can call it by providing it the shipMethodId to print the desired indicator as below.How would I put that into a new field added to the Gridview? I don't think it's part of the dataitem?
I've tried all kinds of variations of this: _indicator, Indicator, indicator Eval = etc.
<asp:TemplateField HeaderText="Ind">
<ItemTemplate>
<% =Indicator %>
</ItemTemplate>
</asp:TemplateField>
Code: Select all
<% GetIndicator(some shipmethod Id here)%>