RESOLVED[02/03] big datagrid problem for web application
Currently, I have a static datagrid on a webapplication. I was doing some research and it seems there are no pointers on this datagrid .I have multiple records been shown in the grid from a SQL query from time to time instead of a single record. And when either result occurs in the grid, I want to go the next page when I press a button.
I want my information from the grid to show up in textboxes on the next page when I do a Server.transfer(""). However, I want the grid to be selectable so that whatever row is selected that the items in the grid row selected appear in the next page's textboxes. The best I have found is to play with the grid color to highlight in yellow during onclick which looks like this:
Code:
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
If (e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer) And _
(e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
e.Item.Attributes.Add("onClick", "this.style.backgroundColor='Yellow'; this.style.color='Black'")
If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='Gainsboro'; this.style.color='Black'")
End If
If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer And e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='White'; this.style.color='Black'")
If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='Whitesmoke'; this.style.color='Black'")
End If
Then I would store the values here:
Code:
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles btnOpen.Click
context.Items("Storage1") = DataGrid1.Items(0).Cells(0).Text
context.Items("Storage2") = DataGrid1.Items(0).Cells(1).Text
context.Items("Storage3") = DataGrid1.Items(0).Cells(2).Text
context.Items("Storage4") = DataGrid1.Items(0).Cells(3).Text
context.Items("Storage5") = DataGrid1.Items(0).Cells(4).Text
Context.Items("Storage6") = DataGrid1.Items(0).Cells(5).Text
Server.Transfer("Verify_Iss.aspx")
and then by the next page verify.aspx do the following:
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
TextBox1.Text = Context.Items("Storage1")
TextBox2.Text = Context.Items("Storage2")
TextBox3.Text = Context.Items("Storage3")
end if
Right now it just takes the first row from the grid and that 's it on how it is written currently.
Re: [02/03] big datagrid problem for web application
In your datagrid, you can create an ItemTemplate column. Do so, and put checkboxes in it. The user will check the checkboxes he wants, press the button, and all you have to do is loop through the datagrid, find out which rows have had their checkboxes selected.
Is that pointing you in the right direction? Because this is a somewhat common scenario that you're talking about, it's best that you try to do this yourself.
So forget the onclick bit, but use checkboxes instead.
Re: [02/03] big datagrid problem for web application
Yes. And thank you very much sir may I have another ?:)
Re: [02/03] big datagrid problem for web application
Re: [02/03] big datagrid problem for web application
Quote:
Originally Posted by mendhak
Another what? :confused:
Sorry. that's an old american joke lost in the subtext.:D