I would like to learn how to get a specific cells value, and populate a textbox with that specific value not by selecting the cell either. i.e.
Column 4, Row 1 cell = textbox.text, perferably in VB
I am new at this so, please be nice. I am sure it is something right under my nose just over thinking it.
Hi Dylan,
I had to do something similar. From what I understand, info from the grid is only available to the form using client-side events. So for me, I went into the grid's properties, chose "display layout" and then "ClientSideEvents" then I picked an event. Then I added javascript that looked like this(in my case, I wanted to take the text from a columns footer and then display it in a text box):
function UltraWebGrid1_MouseOutHandler(gridName, cellId, key)
{
var row = igtbl_getRowById(cellId); var nextRow = row.getNextTabRow(false, true);
var grid = igtbl_getGridById(gridName); var col = igtbl_getColumnById("UltraWebGrid1_rc_0_7"); document.getElementById(Subtotal).value = (col.getFooterText());
}
I had to run the page and look at it with "View Source" to see what name the page called the grid and cell(UltraWebGrid1_rc_0_7) at runtime
Hope this helps,
JCC
JCC,
Thanks for the help but I actually figured it out almost right after I posted my cry for help. I had been working on it for hours and I was by smidge:
Me.wtxtARate.Text = dsText.Tables("TextTable").dsRow.ToString
I had the row meet a column like a gird point on a map. So I thought this was the right answer though:
Me.wtxtARate.Text = dsText.Tables("TextTable").Rows(0)("AccrualRate").ToString
Here is the whole Sub() for anyone in the future.
Private Sub btnGo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGo.Click
Dim strLoanID As String
Dim ds As New DataSet
Dim da As New SqlClient.SqlDataAdapter
Dim dsText As New DataSet
Dim daText As New SqlClient.SqlDataAdapter
strLoanID = txtLoanID.Text
If strLoanID = "" Then
txtLoanID.Text = "Enter Loan ID"
Else
'Populates grid when equal to specified loan id
ds.Tables.Add("LoadTable")
da.SelectCommand = New SqlClient.SqlCommand(MainQuery.Replace("@loanID", strLoanID.ToString), Me.cn)
da.Fill(ds.Tables("LoadTable"))
Me.wgrdAccRate.DataSource = ds
Me.wgrdAccRate.DataMember = "LoadTable"
Me.DataBind()
'Populates the wtxtARate when equal to specified loan id
dsText.Tables.Add("TextTable")
daText.SelectCommand = New SqlClient.SqlCommand("SELECT AccrualRate FROM acLoanAccrualRate " & vbCrLf & _
"WHERE loanID = " & strLoanID, Me.cn)
daText.Fill(dsText.Tables("TextTable"))
Me.wtxtARate.Text = dsText.Tables("TextTable").Rows(0)("AccrualRate").ToString()
End If