开发者

How to export a GridView data into .csv file in asp.net

开发者 https://www.devze.com 2023-04-03 23:10 出处:网络
i have a issue while exporting Gridview data into .csv file.I have followed a link to export This link i have follow please chec开发者_Python百科k it. When I run the application it creates just heade

i have a issue while exporting Gridview data into .csv file.I have followed a link to export This link i have follow please chec开发者_Python百科k it. When I run the application it creates just header names, remaining body fields always show null values. Please help me how to export GridView data into .csv file


Maybe your GridView use the template fields, and your property «.Text» is always null.

Suggestion: Put a break-point just in «sw.Write(dr.Cells[i].Text);» and check your Cells[i] object. Search for the property you want to put in the file. Probably you will need to do some cast to catch the right value you want.

Ex.: sw.Write(((TextBox)dr.Cells[i].Controls[0]).Text);

Hope this helps.

0

精彩评论

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

关注公众号