Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BiggestBookWeb.BLHelper;

namespace BiggestBookWeb.Forms
{
public partial class MyList : System.Web.UI.Page
{
DataSet oDS = new DataSet();
DataTable dt = new DataTable();

protected void Page_Load(object sender, EventArgs e)
{

int counta = Convert.ToInt32(Session["AddToListCount"]);
for (int i = 0; i <= counta; i++)
{
string keyword = Convert.ToString(Session["AddToList" + i]);

oDS = SearchHelper.getCompareResultByKeywords(keyword);
if (i == 0)
{
foreach (DataColumn col in oDS.Tables[0].Columns)
{
dt.Columns.Add(col.ColumnName, col.DataType);
}
}
if(keyword != "")
{
dt = tblGridRow();
}
}
GridView1.DataSource = dt;
GridView1.DataBind();
}

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Remove")

{


//dt = tblGridRow();
//dt.Rows.RemoveAt(e.);
//GridView1.DataSource = dt;
//GridView1.DataBind();

}
}
public DataTable tblGridRow()
{



int counta = 1;
for (int i = 0; i <counta;> {
DataRow dr = dt.NewRow();
dr["LG_ITEM_DSC"] = oDS.Tables[0].Rows[0]["LG_ITEM_DSC"].ToString();
dr["MFR_SKU_NUM"] = oDS.Tables[0].Rows[0]["MFR_SKU_NUM"].ToString();
string Price = oDS.Tables[0].Rows[0]["LIST_AMT"].ToString();
int length = Price.Length;
dr["LIST_AMT"] = Price.Remove(length - 2, 2);
dr["BRND_LOGO"] = oDS.Tables[0].Rows[0]["BRND_LOGO"].ToString();
dr["INV_UN_CDE"] = oDS.Tables[0].Rows[0]["INV_UN_CDE"].ToString();
dt.Rows.Add(dr);



}



return dt;


}


protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

}
}
}
Posted

1 solution

use like this
C#
if (e.CommandName == "Remove")
GridView1.Rows.Remove(GridView1.SelectedRow);  
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900