Windows XP - Grid View - Asked By Tamer Hatoum on 20-May-09 04:46 AM

HI..

I have a grid view containing a select raw button . but I want to remove that column and to allow the whole raw clickable and to make a function...

here is my code..

GGVCarHistory.Columns.Clear();

SelectHistoryDateTimeStr();

GdsCarHistory.ConnectionString = WebConfigurationManager.ConnectionStrings["AVLConnectionString"].ConnectionString;

string HistoryGridViewCount = System.Web.Configuration.WebConfigurationManager.AppSettings["HistoryGridView"];

string TrackingSqlCommand = "SELECT TOP (" + HistoryGridViewCount + ") * FROM Tracking WHERE (DeviceNumber = @PDeviceNumber) AND DateDiff(second,@StartDateTime,TimeStamp) >=0 AND DateDiff(second,@EndDateTime,TimeStamp)<=0 ORDER BY TimeStamp desc";

GdsCarHistory.SelectCommand = TrackingSqlCommand;

GdsCarHistory.SelectParameters.Clear();

GdsCarHistory.SelectParameters.Add("PDeviceNumber", CheckCarDeviceId);

GdsCarHistory.SelectParameters.Add("StartDateTime", (string)Session["StartDate"]);

GdsCarHistory.SelectParameters.Add("EndDateTime", (string)Session["EndDate"]);

GGVCarHistory.DataSourceID = GdsCarHistory.ID;

GGVCarHistory.AutoGenerateColumns = false;

string[] KeyNames = new string[] { "ID" };

GGVCarHistory.DataKeyNames = KeyNames;

//設定GridView屬性

GGVCarHistory.AllowPaging = true; //設定分頁

GGVCarHistory.AllowSorting = true; //設定排序

GGVCarHistory.Font.Size = 10; //設定字型大小

GGVCarHistory.GridLines = GridLines.Both; //設定格線

GGVCarHistory.PageSize = 10;

GGVCarHistory.EnableSortingAndPagingCallbacks = false; //非同步Callback模式

GGVCarHistory.PagerSettings.Position = PagerPosition.TopAndBottom; //分頁位置

GGVCarHistory.PagerStyle.HorizontalAlign = HorizontalAlign.Center; //分頁對齊

GGVCarHistory.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;

BoundField XField = new BoundField();

BoundField YField = new BoundField();

BoundField SpeedField = new BoundField();

BoundField TimeField = new BoundField();

CommandField SelectCommand = new CommandField();

CommandField selectField = new CommandField();//

selectField.ButtonType = ButtonType.Link;

selectField.ShowSelectButton = true; //顯示選取按鈕

selectField.HeaderText = "Select";

selectField.SelectText = "Select";

selectField.ItemStyle.Wrap = false;


XField.DataField = "X"; //指定資料來源欄位

XField.HeaderText = "X"; //設定欄位標頭名稱

XField.SortExpression = "X";//指定排序欄位名稱

XField.ItemStyle.Wrap = false;

YField.DataField = "Y"; //指定資料來源欄位

YField.HeaderText = "Y"; //設定欄位標頭名稱

YField.SortExpression = "Y";//指定排序欄位名稱

YField.ItemStyle.Wrap = false;

SpeedField.DataField = "Speed"; //指定資料來源欄位

SpeedField.HeaderText = "Speed"; //設定欄位標頭名稱

SpeedField.SortExpression = "Speed";//指定排序欄位名稱

SpeedField.ItemStyle.Wrap = false;

TimeField.DataField = "TimeStamp"; //指定資料來源欄位

TimeField.HeaderText = "TimeStamp"; //設定欄位標頭名稱

TimeField.SortExpression = "TimeStamp";//指定排序欄位名稱

TimeField.ItemStyle.Wrap = false;

GGVCarHistory.Columns.Add(selectField);

GGVCarHistory.Columns.Add(XField);

GGVCarHistory.Columns.Add(YField);

GGVCarHistory.Columns.Add(SpeedField);

GGVCarHistory.Columns.Add(TimeField)

Santhosh N replied to Tamer Hatoum on 20-May-09 04:59 AM

Check this one explaining the editable gridview on windows application explaining all the possible events along with the code snippets..

http://msdn.microsoft.com/en-us/library/ms993231.aspx

Re - Ravenet Rasaiyah replied to Tamer Hatoum on 20-May-09 05:39 AM

sorry - Tamer Hatoum replied to Ravenet Rasaiyah on 20-May-09 07:11 AM

have not answered my question :(..