Hi - sorry for the confusion - I was brain dead by the
time I posted this. Hopefully this will make more sense
(code below).
I have an .aspx page containing a datagrid (DG) and a
table below (DetailTable). The datagrid is populated
from a dataset created from a SQLServer database. There
are several hidden fields in the datagrid in
addition to the fields displayed. When the user clicks
the "select" button, client side script grabs
all the fields from the datarow and populates the
corresponding fields in the detail table below the
datagrid. The users are at a remote site on the far side
of a very slow LAN line and I am trying to
avoid as many round-trips to the server as I can because
of this.
If I leave the "select" button visible in the datagrid,
and the user clicks it, the detail table below
is quickly updated with the datagrid row's info. I would
like to hide the select button (need more screen
real estate), and allow the user to click anywhere in a
row and have the detail table below update as
it does when the select button is clicked. I've adapted
code from an example in MSDN to do this,
but when I click on a datagrid row, the detail table
doesn't update, and the datagrid drops out of the
HTML page leaving only the detail table. It's this problem
I'm trying to understand and fix.
Does this help? Any ideas or suggestions?
tia,
Sue
in code-behind page
Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Me.cn.ConnectionString =
ConfigurationSettings.AppSettings("ConnectionString")
DA = New SqlClient.SqlDataAdapter("select * from
applicationview order by name", cn)
Me.DS.DataSetName = "DS"
Me.DA.Fill(Me.DS)
cn.close
' dg is the datagrid object
dg.databind()
Call ClientScript(sender, e)
Else
Page.DataBind()
End If
End Sub
Private Sub ClientScript(ByVal sender As Object, ByVal e
As EventArgs)
Me.ClientScriptString = "<script language=VBScript>"
& vbCrLf _
& " sub FillDetailTable(AppID, CaseNo, CaseType,
MyName, MyDate, MyStatus, Verifier, EvaluatedVerified,
Recommendation, FeeRecommendation,
ContributionRecommendation,
ContributionAmountRecommendation, HearingRequested,
HearingDecision, FeeOrdered, ContributionOrdered,
ContributionAmountOrdered, Adjudication) " & vbCrLf _
& " document.all(" & Chr(34) & "DTTableHeader" & Chr
(34) & ").innertext = AppID " & vbCrLf _
...<snip>...
& " end sub " & vbCrLf & "<" _
& "/" _
& "script>"
If (Not IsClientScriptBlockRegistered
("FillDetailTable")) Then
RegisterClientScriptBlock("FillDetailTable",
ClientScriptString)
End If
End Sub
Private Sub DG_ItemDataBound(ByVal source As Object, ByVal
e As System.Web.UI.WebControls.DataGridItemEventArgs)
Handles DG.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or
e.Item.ItemType = ListItemType.AlternatingItem Then
Dim b As HtmlControls.HtmlInputButton
b = CType(e.Item.Cells(0).Controls(1),
HtmlControls.HtmlInputButton)
b.Attributes.Add("onclick", "FillDetailTable('" _
& GetTableHeader(Trim(e.Item.Cells(1).Text))
& "','" _
& GetTextBox(Trim(e.Item.Cells(2).Text)) & "','" _
& GetDropDownIndex("CaseType", Trim(e.Item.Cells
(3).Text)) & "','" _
<snip>
e.Item.Cells(1).Attributes("onclick") =
Page.GetPostBackClientHyperlink(b, "onclick")
e.Item.Cells(2).Attributes("onclick") =
Page.GetPostBackClientHyperlink(b, "onclick")
e.Item.Cells(3).Attributes("onclick") =
Page.GetPostBackClientHyperlink(b, "onclick")
e.Item.Cells(4).Attributes("onclick") =
Page.GetPostBackClientHyperlink(b, "onclick")
<snip>
End If
End Sub
on .aspx page
<%@ Page Language="vb" AutoEventWireup="false"
trace="True" Codebehind="default.aspx.vb"
Inherits="indigentverification.indigentverification._defaul
t"%>
<snip>
<HTML>
<snip>
<form id="ThisForm" runat="server">
<asp:datagrid id="DG" runat="server">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<INPUT id="SelectButton" runat="server"
type="button" value="Select" NAME="SelectButton">
</ItemTemplate>
</asp:TemplateColumn>
<asp:boundcolumn HeaderText="App ID"
SortExpression="App ID" DataField="AppID"
ReadOnly="True" />
<asp:BoundColumn Headertext="Case No"
SortExpression="CaseNo" DataField="CaseNo"
ReadOnly="True" />
<snip>
<asp:boundcolumn
DataField="ContributionAmountOrdered" Visible="False" />
<asp:BoundColumn DataField="Ajudication"
Visible="False" />
</Columns>
</asp:datagrid>
<table id="DetailTable" runat="server">
<tr>
<td colspan="6" align="center"
bgcolor="MidnightBlue"><asp:Label ID="DTTableHeader"
runat="server" /></td>
</tr>
<tr>
<td width="12%" class="xxsmall">Case No:</td>
<td><asp:textbox id="DTCaseNoTextBox"
Runat="server" /></td>
<td width="12%" class="xxsmall">Case Type:</td>
<td><asp:dropdownlist id="DTCaseTypeDropDown"
Runat="Server" /></td>
<td width="12%" class="xxSmall">Name:</td>
<td><asp:textbox id="DTNameTextBox"
runat="server" /></td>
</tr>
<tr>
<td class="xxsmall">Date:</td>
<td><asp:textbox id="DTDateTextBox"
Runat="server" /></td>
<td class="xxsmall">Status:</td>
<td><asp:dropdownlist id="DTStatusDropDown"
Runat="server" /></td>
<td class="xxsmall">Verifier:</td>
<td><asp:dropdownlist id="DTVerifierDropDown"
Runat="server" /></td>
</tr>
<tr>
<snip>
<td align="center" colSpan="3"><asp:button
id="DTSaveButton" Runat="server" CssClass="Button" /></td>
</tr>
</table>
</form>
</body>
</HTML>