473,491 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Datagrid disappearing - client side coding

Sue
I have a datagrid populated with 6 visible read-only
labels and several hidden fields. Below the datagrid, I
have a table with various textboxes, dropdowns, etc. I've
managed to decypher the client-side coding needed for the
user to click a "select" button (HTMLButton) in column 0
of the datagrid and have the table objects auto-fill with
corresponding values from the dataset row in the datagrid
without making a roundtrip to the server.

I am trying to add code in the datagrid's itemdatabound to
allow the user to click any place in a row and have
the "onclick" client-side button code fire. I've been
looking at Page.GetPostBackClientHyperlink, however I'm
not using a hyperlink button, and when I click anywhere on
the datagrid, it disappears, leaving only the table.

Any ideas on why this is munching my datagrid? Or how to
fix this so it works?

tia,
Sue
Nov 18 '05 #1
8 3030

Hi Sue,

Thanks for posting in this group.
I think there are several unclear place in your statement.
You want: the table objects auto-fill with corresponding values from the
dataset row in the datagrid without making a roundtrip to the server in the
client button_click event.
But actually, dataset is an object of server side, how can you get the
server side dataset value in client button_click event without roundtrip to
server?
Also, datagrid's itemdatabound event is also the server side event.

I think you need explain your solution more clear to us, so that we can
help you well.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #2
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("ConnectionStrin g")
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.indigentverificatio n._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>

Nov 18 '05 #3

Hi,

Thanks for your feedback.
Based on your statement, you have succeeded get this done in select
button's client side click event.
In your code, I see that you register datagrid row's onclick event with
onclick method(Client side). I think first, you should check whether your
registered client side onclick method is called when clicking the datagrid
row.
If your datagrid row click can trigger the client side onclick method, I
think you can succeed invoke the same code as select button's to fill the
table.

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #4

Hi,

Thanks for your feedback.
Based on your statement, you have succeeded get this done in select
button's client side click event.
In your code, I see that you register datagrid row's onclick event with
onclick method(Client side). I think first, you should check whether your
registered client side onclick method is called when clicking the datagrid
row.
If your datagrid row click can trigger the client side onclick method, I
think you can succeed invoke the same code as select button's to fill the
table.

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #5
Sue
check whether your
registered client side onclick method is called when clicking the datagridrow.
If your datagrid row click can trigger the client side onclick method, Ithink you can succeed invoke the same code as select button's to fill thetable.


The onclick method fires just fine when clicking the
Select button. The onclick method isn't called when
clicking anywhere else in the datarow. And, of course,
there's no way to step through client-side script (is
there?) to see what's happening, or not happening. Any
suggestions on where to look for what's missing?

tia,
Sue
Nov 18 '05 #6

Hi Sue,

You can debug the client side script through Microsoft Script debugger, the
article below tells you how to debug client side script:
http://support.microsoft.com/?id=317699

In your application, you associate the select button's click event with
datagrid row's click event through:
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")
I think you'd better check if the return of
Page.GetPostBackClientHyperlink(b, "onclick") is the correct client script.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #7
Sue
>You can debug the client side script through Microsoft
Script debugger, the

Ok, script debugger leads me through several validator
scripts which "die" at: function anonymous()
Validator.OnChange() end function, at which point I get
dumped back on my web page sans the datagrid. I abandoned
trying to get "click anywhere on row" to work and now this
is happening when I click on my select button (which has
now been changed to a linkbutton to virtually duplicate
the MSDN article example). Not knowing the underpinings of
the system supplied functions used in validations, why and
what "anonymous()" is supposed to do is a mystery to me.
Any suggestions now?

Sue
Nov 18 '05 #8

Hi Sue,

Based on my understanding, I think during your client script trace, you
find there are "automated" client validation code generated( function
anonymous() Validator.OnChange() end function).

It seems that Asp.net will generate client validation script code for your
onchange event.

Using a custom validation control is generally the safest approach. Add a
custom validation control which is not linked to any controlView the page
in HTML view and make sure that this custom validation control is LAST.
Then it will be the last control added the array of validation controls and
will be the last one to be evaluated.

This may workaround your problem.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
322
by: John Good | last post by:
Hi I use the Datagrid webcontrol on my web page, and I use the following client-side javascript to duplicate the current row to the datagrid. But when I loop through the data in datagrid from...
4
5330
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
3
2489
by: Kenneth | last post by:
Hi, In a webform I have a datagrid in a certain position using gridlayout. <asp:DataGrid id="dgrdSkada" style="Z-INDEX: 107; LEFT: 16px; POSITION: absolute; TOP: 200px" runat="server"...
2
5653
by: Manish | last post by:
Hey folks I am having a weird problem in ASP .Net. My page is in C#. I have a datagrid, which populates based on selection in drop down box on ASP page. This datagrid has template textbox colum in...
4
4763
by: Neven Klofutar | last post by:
Hi, I need to create the following ... I have DataGrid filled with information (ID, name, price ...). I need to call a function when I click on the item in the DataGrid (and pass ID as an...
2
1945
by: charliewest | last post by:
I am dynamically creating my datagrid, building each column in real-time via code-behind (using c#). The only way i have read to add ImageButtons to my grid dynamically is by creating a separate...
2
1427
by: Maarten | last post by:
Hi all, I have a datagrid with questions where the user has to make a choice (yes or no questions) But for some questions there are rules, like if you choose (yes or no) for some questions I...
7
2487
by: rn5a | last post by:
The first column of a DataGrid has a CheckBox for all the rows. I want that when users check a CheckBox, the BackColor of that entire row in the DataGrid should change to a different color. To...
1
1577
by: Andrew Wan | last post by:
Is it possible to make some of the DataGrid functionality to client-side? Such as the Edit, Update, Cancel, Delete functionality? Everytime I click on a row's Edit button, I wait 2 seconds...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.