Click here to Skip to main content
15,915,509 members

Comments by bobb024 (Top 41 by date)

bobb024 13-May-15 14:53pm View    
yes, this is a control that lives on an ASPX page and below is the sort method

protected void SortGridView(string sortExpression, string direction)
{
DataTable dataTable = SourceTable;

if (dataTable != null)
{
DataView dataView = new DataView(dataTable);
dataView.Sort = sortExpression + " " + direction;
SourceTable = dataView.ToTable();
GridView1.DataSource = SourceTable;
GridView1.DataBind();
int pageindex = GridView1.PageIndex;

}
}

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
isSort = true;

string sortExpression = e.SortExpression;
ViewState["SortExpression"] = sortExpression;

if (GridViewSortDirection == SortDirection.Ascending)
{
isAscend = true;
SortGridView(sortExpression, "ASC");
GridViewSortDirection = SortDirection.Descending;
}
else
{
isAscend = false;
SortGridView(sortExpression, "DESC");
GridViewSortDirection = SortDirection.Ascending;
}
}
bobb024 5-May-15 14:16pm View    
DropDownList ddlChanges = row.Cells[qtyColumn.Ordinal].Controls[0] as DropDownList;
bobb024 4-May-15 16:39pm View    
it shows 20 visually but when I fire the button, it is not saving correctly
bobb024 2-May-15 15:58pm View    
I added the save method above. Also for the original value comment, for instance, the row has a value of 1 in the drop down list, then I sort the list and change the quantity to 20, it is still saving the first value (ie 1)
bobb024 2-May-15 15:54pm View    
Deleted
<pre lang="c#">
public List<string> GetLevelSignsToBeSaved()
{
List<string> selectedIds = new List<string>();

List<stat> stats = new List<stat>();

DataColumn promoColumn = SourceTable.Columns["Column_PROMOTION"];
DataColumn qtyColumn = SourceTable.Columns["Column_QTY"];
DataColumn promo2Column = SourceTable.Columns["Column_ADDPROMO"];
DataColumn qty2Column = SourceTable.Columns["Column_2QTY"];
DataColumn printedColumn = SourceTable.Columns["Column_PRINT"];

if (promoColumn != null || qtyColumn != null || promo2Column != null || qty2Column != null)
{
foreach (GridViewRow row in this.GridView1.Rows)
{
List<levelsign> Signs = new List<levelsign>();
LevelSign LevelSign = new LevelSign();
LevelSign secondSign = new LevelSign();

if (promoColumn != null)
{
if (row.Cells[promoColumn.Ordinal].Controls.Count > 0)
{
DropDownList ddlChanges = row.Cells[promoColumn.Ordinal].Controls[0] as DropDownList;
if (ddlChanges is DropDownList)
{
if (ddlChanges.SelectedValue != "" && Convert.ToInt32(ddlChanges.SelectedValue) != 0)
{
string levelSignId = ddlChanges.ID.Split('_')[2];
LevelSign = LevelManager.GetLevelSignByLevelSignIdSimple(Convert.ToInt32(levelSignId));
if (LevelSign.StampID == Convert.ToInt32(ddlChanges.SelectedValue))
{
//do nothing
}
else
{
LevelSign.StampID = Convert.ToInt32(ddlChanges.SelectedValue);
stats.Add(StatManager.makeStat(LevelSign.SignID, LevelSign.LevelID, LevelSign.LevelID, LevelSign.sign.DepartmentID, LevelSign.StampID, (int)tsUtil.stattype.vChangeSizeAtMatrix, DateTime.Now, LevelSign.LevelSignQuantity));
}
}
}
}
}

if (qtyColumn != null)
{
if (row.Cells[qtyColumn.Ordinal].Controls.Count > 0)
{
DropDownList ddlChanges = row.Cells[qtyColumn.Ordinal].Controls[0] as DropDownList;
if (ddlChanges is DropDownList)
{
if (ddlChanges.SelectedValue != "" && Convert.ToInt32(ddlChanges.SelectedValue) != 0)
{
if (LevelSign.LevelSignQuantity == Convert.ToInt32(ddlChanges.SelectedValue))
{
//do nothing
}
else
{
LevelSign.LevelSignQuantity = Convert.ToInt32(ddlChanges.SelectedValue);
stats.Add(StatManager.makeStat(LevelSign.SignID, LevelSign.LevelID, LevelSign.LevelID, LevelSign.sign.DepartmentID, LevelSign.sign.StampID, (int)tsUtil.stattype.vChangeQuantityAtMatrix, DateTime.Now, LevelSign.LevelSignQuantity));
}
}
}
}
}


if (promo2Column != null)
{
if (row.Cells[promo2Column.Ordinal].Controls.Count > 0)
{
DropDownList ddlChanges = row.Cells[promo2Column.Ordinal].Controls[0] as DropDownList;
if (ddlChanges is DropDownList)
{