Hi experts,
may I know is this the way to convert sqldatetime to string at the grid view footer? Cause there is an error for this word: .RowIndex
DateTime startDate = Convert.ToDateTime(gvContract.DataKeys[e.RowIndex].Value.ToString());
Thanks:D
Loading
Suthish NairPosted Feb 16, 2011, 2:54 AM
Suthish NairPosted Feb 14, 2011, 10:33 AM
DateTime startDate = Convert.ToDateTime(gvContract.DataKeys[e.CommandArgument].Value).ToString("dd-MMM-yyyy");
or example,
string values = gvContract.DataKeys[Convert.ToInt32(e.CommandArgument)].Value.ToString();
or,
int i = Convert.ToInt32(e.CommandArgument);
GridViewRow gvRow = GridView1.Rows[iIndex];
string s = GridView1.DataKeys[i].Values["ID"].ToString().Trim();
Becky BloomwoodPosted Feb 14, 2011, 9:57 AM
Server Error in '/VRM_WebSite' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'System.Web.UI.WebControls.GridViewCommandEventArgs' does not contain a definition for 'RowIndex' and no extension method 'RowIndex' accepting a first argument of type 'System.Web.UI.WebControls.GridViewCommandEventArgs' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 266: { Line 267: Line 268: DateTime startDate = Convert.ToDateTime(gvContract.DataKeys[e.RowIndex].Value).ToString("dd-MMM-yyyy"); Line 269: Line 270:Source File: c:\Users\Maggie\Desktop\Peggie\Peggie\Deployment Source\Phase 1\Deployment 25 Nov for StarHub\VS Projects Source\VRM_WebSite\app\vrm\ContractManagement.aspx.cs Line: 268
Thks!
Suthish NairPosted Feb 14, 2011, 9:46 AM
gvContract.DataKeys[e.RowIndex].Value ==> This will be always string.
Convert to DateTime
DateTime startDate = Convert.ToDateTime(gvContract.DataKeys[e.RowIndex].Value).ToString("dd-MMM-yyyy");
Becky BloomwoodPosted Feb 14, 2011, 9:38 AM
Madhu KPosted Feb 14, 2011, 8:57 AM