Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
hi all i am begginer in C# so can u convert this vb code into C# please.. please reply fast....
 

 

Protected Function GetIndexForColumn(ByVal gridToSearch As GridView, ByVal columnHeaderToSearch As String, ByVal templateColumnCount As Integer, ByVal selectOrEditVisible As Boolean) As Integer
 
Dim Index As Integer
 
For Index = templateColumnCount To gridToSearch.Columns.Count - 1
         If gridToSearch.Columns(Index).ToString = columnHeaderToSearch Then
 
              If selectOrEditVisible = True Then
 
                      Return Index + 1
               Else
 
                    Return Index
            End If
 
    End If
 
Next
 
End Function
 
lineColIndex = GetIndexForColumn(OpenOrdersGridView, "Ln#", 1, True)selectedOrderNumber = OpenOrdersGridView.Rows(Integer.Parse(e.CommandArgument.ToString())).Cells(orderColindex).Text
Regards
Posted 24-Dec-12 17:17pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

protected int GetIndexForColumn(GridView gridtoSearch, string columnheaderToSearch, int templatecolumncount, bool selectOrEditVisible)
{
    int index = 0;
    for (index = templatecolumncount; index < gridtoSearch.Columns.Count - 1;index++)
    {
        if (gridtoSearch.Columns[index].ToString() == columnheaderToSearch)
        {
            if (selectOrEditVisible)
            {
                 return index + 1;
            }
            return index;
        }
    }
    return 0;
}
  Permalink  
v2
Comments
Member 9644686 at 25-Dec-12 0:20am
   
thank you very much...
ridoy at 25-Dec-12 1:35am
   
+5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

^]
 
Keep this link for your future reference. You can convert your code from here.
 
- KiranKumar Roy
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

There are alot of code conversion tools available on line to convert code from VB to C#. Here are a few
^]
^]
 
You can ^] for more links
 
You may also find this CP article helpful
^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,725
1 OriginalGriff 6,696
2 CPallini 5,315
3 George Jonsson 3,589
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web02 | 2.8.140922.1 | Last Updated 25 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100