Web Forms :: How To Get Column Index Of A Particular Name
May 7, 2015
Id name
1 xyz
2 pqr
5 mnp
3 iuy
4 lkj
in a sql table like this how to get the column index of a particular name like out put will be for "mnp" index is 3....(not according to id) what will be the sql query or if it is a datatable then what will be the code to find the column index...
I have a grid view with 4 columns and 12 rows. Getting the row index is not problem; ;however, I cannot find a way to get the column index of the cell that i select.
Is there a way to find out which column is selected in the Gridview row command? When I click on a gridview row in a specific column, is there a way to get the column index of the selected row?
I have been trying to hide a column but make use of the value in another function but the function i am trying to hide it give me and error at the embolded line. System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Public Sub FetchDetails() Dim valtable As DataTable = New DataTable() valtable.Columns.Add("LINK") valtable.Columns.Add("WATCH PERIOD") valtable.Columns.Add("DAY ENTRY") valtable.Columns.Add("listid") Dim seltext As String = "SELECT [Watchlistname], [Watchlisturl], [Watchlistdate],[listid] FROM [Watchlist]" Dim madap As SqlDataAdapter = New SqlDataAdapter(seltext, Connection()) Dim mdset As DataSet = New DataSet() Dim i As Integer = 0, pager As Integer = 0 madap.Fill(mdset, "WATCHLIST") Session("tab") = mdset.Tables("WATCHLIST") For Each arow As DataRow In Session("tab").Rows Dim valrow As DataRow = valtable.NewRow() valrow("LINK") = arow("Watchlisturl") valrow("WATCH PERIOD") = arow("Watchlistname") valrow("DAY ENTRY") = arow("Watchlistdate") valrow("listid") = arow("listid") valtable.Rows.Add(valrow) Next 'Dim str As String = ChrW(8358) gridWatchlist.DataSource = valtable gridWatchlist.DataBind() gridWatchlist.HeaderRow.Cells(1).Visible = False gridWatchlist.HeaderRow.Cells(2).Text = "WATCH PERIOD" gridWatchlist.HeaderRow.Cells(3).Text = "DAY ENTRY" gridWatchlist.Columns(4).Visible = False End Sub
i know how to find the index of selected row in asp gridview , but i need to find the index of selected column in asp gridview ?for ex:i have i gridview contains columns with header ( the header is the primary key i looking for ) , this grid contain linkbutton , i want to get the column header name on click on linkbutton ?
I have a gridview and the OnRowDataBound event is linked to this function:
if (e.Row.RowType == DataControlRowType.DataRow) { ThisRow = e.Row.DataItem as MyObjectModel; if (ThisRow.Property1 == null) { e.Row.Cells[5].Text = "-"; }
This code looks at the value of a property of the object in the data source and if it's null, converts the null to display "-" in column 5. The problem I'm having is that if I change the order of the columns of the gridview, then I need to change the index of every other modification. What I'd like to do is change the statement "e.Row.Cells[5].Text" to something that says "the cell whose column header is xyz".
I am trying to write a small method to loop through and find a GridView Column by its Index, since it can change position based on what might be visible.
Here is what I have so far:
private int GetColumnIndexByName(GridView grid, string name) { foreach (DataColumn col in grid.Columns) { if (col.ColumnName.ToLower().Trim() == name.ToLower().Trim()) return col.Ordinal; }........
I have a column in SQL Server 2008 called MapLocation which is stored as the geography data type. This column is used to store the location of a building in one table, and the location of landmarks in another table. I have to list all landmarks within 4 miles of a building.
I have a clustered primary key on an automatically generated int column in each table. I assume that I need to create a spatial index on the MapLocation column in the landmarks table. This I guess would aid finding all landmarks within 4 miles.
My problem is that I am not sure what settings to use for this spatial index. I have set the spatial index to have the following settings:
Cells per object: 16 Level 1: Medium Level 2: Medium Level 3: Medium Level 4: Medium Tessalation Scheme: Geography gridAre these the best settings? Am I doing the right thing?
I have two control page in my aspx page. first one left side "tree view",second one right side " form design".Form design will change based on tree view selected index changed.i have 4 level child node(site, master , slave, space). I have seperate forms to each level of node.
cannot update tree node when update the forms. so i reload tree view.
now i need how to auto selected index change to tree node.
ex.
1 parent node
1.1 child node
1.2 child node
i have update "1.2 child node" rename to "1.3 child node"
and reload treeview so it will chage...
how set tree node.selected index = 1.3 child node....
I'm working on a project where we're using Windows Desktop Search (WDS) to index files on a web share and then later allow the user to search via a website for documents in the share.
These documents are transferred to the share via FTP, however it would seem that either the computer never goes idle to index or at some point the indexing stops. Is there a way from the command line or within the program itself to force this to happen without having to re-invent the wheel? Using .NET 3.5 and C#.
Cannot create the clustered index 'RateViewIndex' on view 'NoteToPass.dbo.RateView' because the select list of the view contains an expression on result of aggregate function or grouping column. Consider removing expression on result of aggregate function or grouping column from select list.
I am looking to sort a column on my gridview by simply clicking on the column rather than clicking on the column header. In the design I have been given, the column header will not be shown, and I need to be able to give the user to sort this column, by simply just clicking any where on the column.
AutoGenerateColumns: Flase/True ( i tried both) If i remove the gvOff.Columns[index].HeaderText portions, GridView works fine, but when i put the gvOff.Columns[0].HeaderText, i get the exceptional error.
, i couldn't solve it. If you need further info, inform me.
EDITED:
Hold on! I commented the HeaderText portion and tested int i = gvOffer.Columns.Count; I found count is 0 eventhough the columns print out with DataBind()... Why? NOTE: AutoColumn in this case is set to true. I guess i will have to edit the column names from DataTable.
I'm currently working on a small project and therefore created a gridview, including one bit column which has been linked with a checkbox in both the itemtemplate as the edititemtemplate (autopostback = true).Databinding for these two checkboxes has been linked (two-way) to the bit column.Now I want to display the gridview to end-users. They should be able to just click on the checkbox so they value in the database column gets changed as well (as I want to run update queries behind it), but not passing via the command column 'EDIT'.=> problem I'm having now is that the bit column in the database doesn't get updated.