hi
im creating i webdatagrid and fill with some data but for some reason when i filter columns or group columns the grid does a postback and everything is loaded again, so i put a postback validation on my page load event to avoid reseting the form but now when i filter or group by my data disapear from the grid.
can you help me?
Thanks.
on english please? sorry didnt understand
my question is to handle the postback to avoid refreshing my filters and controls when trying to group by or use grid filters since now im loosing the data whenever one of those two action are made.
Hi Pavcbc,
It sounds like you are using the WebHierarchicalDataGrid and Column Grouping? Whenever a column is grouped, the entire grid posts back. It ends up collapsing back to just the root. With filtering, it should just refresh the grid being filtered and its children.
regards,David Young
i really dont know, im just running the code from my pc where i develop
this is my code
Imports
Microsoft.SqlServer
Partial
Public Class
_Default
Inherits
System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me
.Load
If Not IsPostBack
Then
LoadDates()
LoadReleaseDates()
End
If
Sub
Private Sub
Dim mycon As SqlClient.SqlConnection = New
SqlClient.SqlConnection
Dim Mycmd As
SqlClient.SqlCommand
Dim MyRd As
SqlClient.SqlDataReader
Try
mycon.ConnectionString =
"Data Source=MyServer;Initial Catalog=MyDataBase;User Id=MyUser;Password=MyPass;"
mycon.Open()
Mycmd =
New SqlClient.SqlCommand("exec sp_GetFromTo"
, mycon)
MyRd = Mycmd.ExecuteReader()
Dfrom.Items.Clear()
Dto.Items.Clear()
Do While
MyRd.Read
Dfrom.Items.Add(MyRd.GetValue(0))
Dto.Items.Add(MyRd.GetValue(0))
Loop
Dfrom.Text = Format(Today,
"yyyy-MM"
)
Dto.Text = Dfrom.Items(Dfrom.Items.Count - 1).Text
mycon.Close()
Catch Ex As
Exception
If mycon.State = ConnectionState.Open Then
New SqlClient.SqlCommand("SELECT DISTINCT RELEASEDATE FROM TBL_PSI WITH (NOLOCK) ORDER BY RELEASEDATE"
DRelease.Items.Clear()
DRelease.Items.Add(MyRd.GetValue(0))
DRelease.Text = DRelease.Items(DRelease.Items.Count - 1).Text
DisplayGrid()
Dim MyDa As
SqlClient.SqlDataAdapter
Dim MyDT As New
DataTable
Dim SqlCommand As
String
SqlCommand =
"exec sp_Get_PSI "
& _
"@MonthFrom = '" + Right(Dfrom.Text.Trim, 2) + "', "
"@MonthTo = '" + Right(Dto.Text.Trim, 2) + "', "
"@YearFrom = '" + Left(Dfrom.Text, 4) + "',"
"@YearTo = '" + Left(Dto.Text, 4) + "', "
"@fctbp = " + IIf(Dfctbp.Text.ToUpper = "FCT", "1", "0") + ", "
"@release = '" + DRelease.Text +
"'"
MyDa =
New
SqlClient.SqlDataAdapter(SqlCommand, mycon)
MyDa.Fill(MyDT)
'Show the grid
webgrid.DataSource = MyDT
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles
Button1.Click
Class
Thanks
are you using server side or client side filteration ?
can you post your code ?