You need to give some Column name to the Aggregate function and it is called Alias. Thus change the query as follows
cmd = new SqlCommand("select name,count(name) as NameCount from Sample g roup by name ", con);
And in GridView you need to change the BoundField as follows
<asp:BoundField HeaderText="count" DataField="NameCount" ReadOnly="True" SortExpression="count" />