开发者

GridView DataKeys Always returns Integer value

开发者 https://www.devze.com 2023-04-11 20:36 出处:网络
I have an ASP.NET GridView with DataKeyNames=\"EmployeeNumber\" where EmployeeNumber is the primary key in the Employees table and a foreign key in many other tables.

I have an ASP.NET GridView with DataKeyNames="EmployeeNumber" where EmployeeNumber is the primary key in the Employees table and a foreign key in many other tables.

EmployeeNumber is a varchar field where employee numbers can start with a leading significant 0. In other words, Employee Number 247 != EmployeeNumber 0247. (Ask HR about that one, no it cannot be changed.)

This is causing an issue with my gridview. When I access开发者_如何学JAVA the DataKeys collection it always returns an integer value which returns the wrong employee number.

Is there a way I can get the GridView.DataKeys[0] to return a string instead of an integer. It seems that it is a collection of type object which would lead me to believe that their is a way.

0

精彩评论

暂无评论...
验证码 换一张
取 消