Question about postback

S

SK

Hello,

I have a datagrid, textbox and a button in my page. The
datagtrid
has sorting enabled. But, I am not doing any sorting. Its
just for
test purpose. Now the user enteres some text in the
textbox and
presses the button and it response.writes the value of it.
Now when I
do a sort then the OnItemCreated Method is called, which
again calls
the test function, but it doesnt print the data from the
textbox. It
behaves like the textbox is empy, but it isnt. I can see
the value in
the textbox. I dont understand that all. Can somebody help
out?

Here is the code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim arList As New ArrayList
arList.Add("1")
arList.Add("2")
arList.Add("3")

DataGrid1.DataSource = arList
DataGrid1.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Response.Write(TextBox1.Text)
End Sub

Public Function test()
Response.Write("testme" & TextBox1.Text)
End Function

Private Sub DataGrid1_OnItemCreated(ByVal sender As
Object, ByVal
e As System.Web.UI.WebControls.DataGridItemEventArgs)
Handles
DataGrid1.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Header
test()
End Select
End Sub

Sub Sort(ByVal sender As Object, ByVal e As
DataGridSortCommandEventArgs)

End Sub

Thanks
 
K

Ken Cox [Microsoft MVP]

Hi,

I'm not able to reproduce your problem. The following code outputs the
contents of the textbox in the response.write.

Ken
Microsoft MVP [ASP.NET]


<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server"></asp:datagrid>
<p>&nbsp;</p>
<p>
<asp:textbox id="TextBox1" runat="server"></asp:textbox></p>
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
</form>

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim arList As New ArrayList
arList.Add("1")
arList.Add("2")
arList.Add("3")

DataGrid1.DataSource = arList
DataGrid1.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Write(TextBox1.Text)
End Sub

Public Function test()
Response.Write("testme" & TextBox1.Text)
End Function

Private Sub DataGrid1_OnItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Header
test()
End Select
End Sub

Sub Sort(ByVal sender As Object, ByVal e As
DataGridSortCommandEventArgs)

End Sub
 
S

SK

Hi Ken,

does it work for you even if you click the header in
the datagrid ?

THanks

-----Original Message-----
Hi,

I'm not able to reproduce your problem. The following code outputs the
contents of the textbox in the response.write.

Ken
Microsoft MVP [ASP.NET]


<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1"
 
K

Ken Cox [Microsoft MVP]

Yes, if you add a handler:

Sub Sort(ByVal sender As Object, _
ByVal e As DataGridSortCommandEventArgs)
Response.Write("Sort:" & TextBox1.Text)
End Sub

<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server"
allowsorting="True"></asp:datagrid>
<p>&nbsp;</p>
<p>
<asp:textbox id="TextBox1" runat="server"></asp:textbox></p>
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
</form>


SK said:
Hi Ken,

does it work for you even if you click the header in
the datagrid ?

THanks

-----Original Message-----
Hi,

I'm not able to reproduce your problem. The following code outputs the
contents of the textbox in the response.write.

Ken
Microsoft MVP [ASP.NET]


<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1"
runat="server"> said:
<p> </p>
<p>
<asp:textbox id="TextBox1"
runat="server"> said:
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
</form>

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim arList As New ArrayList
arList.Add("1")
arList.Add("2")
arList.Add("3")

DataGrid1.DataSource = arList
DataGrid1.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Write(TextBox1.Text)
End Sub

Public Function test()
Response.Write("testme" & TextBox1.Text)
End Function

Private Sub DataGrid1_OnItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Header
test()
End Select
End Sub

Sub Sort(ByVal sender As Object, ByVal e As
DataGridSortCommandEventArgs)

End Sub



.
 
S

SK

But I dont want to enter this code in the sort event. it
should call the test function via the onitemcreated event.

-----Original Message-----
Yes, if you add a handler:

Sub Sort(ByVal sender As Object, _
ByVal e As DataGridSortCommandEventArgs)
Response.Write("Sort:" & TextBox1.Text)
End Sub

<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server"
allowsorting="True"></asp:datagrid>
<p> </p>
<p>
<asp:textbox id="TextBox1"
runat="server"> said:
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
</form>


Hi Ken,

does it work for you even if you click the header in
the datagrid ?

THanks

-----Original Message-----
Hi,

I'm not able to reproduce your problem. The following code outputs the
contents of the textbox in the response.write.

Ken
Microsoft MVP [ASP.NET]


<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1"
runat="server"> said:
<p> </p>
<p>
<asp:textbox id="TextBox1"
runat="server"> said:
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
</form>

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim arList As New ArrayList
arList.Add("1")
arList.Add("2")
arList.Add("3")

DataGrid1.DataSource = arList
DataGrid1.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Write(TextBox1.Text)
End Sub

Public Function test()
Response.Write("testme" & TextBox1.Text)
End Function

Private Sub DataGrid1_OnItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Header
test()
End Select
End Sub

Sub Sort(ByVal sender As Object, ByVal e As
DataGridSortCommandEventArgs)

End Sub

Hello,

I have a datagrid, textbox and a button in my page. The
datagtrid
has sorting enabled. But, I am not doing any sorting. Its
just for
test purpose. Now the user enteres some text in the
textbox and
presses the button and it response.writes the value of it.
Now when I
do a sort then the OnItemCreated Method is called, which
again calls
the test function, but it doesnt print the data from the
textbox. It
behaves like the textbox is empy, but it isnt. I can see
the value in
the textbox. I dont understand that all. Can somebody help
out?

Here is the code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim arList As New ArrayList
arList.Add("1")
arList.Add("2")
arList.Add("3")

DataGrid1.DataSource = arList
DataGrid1.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Response.Write(TextBox1.Text)
End Sub

Public Function test()
Response.Write("testme" & TextBox1.Text)
End Function

Private Sub DataGrid1_OnItemCreated(ByVal sender As
Object, ByVal
e As System.Web.UI.WebControls.DataGridItemEventArgs)
Handles
DataGrid1.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Header
test()
End Select
End Sub

Sub Sort(ByVal sender As Object, ByVal e As
DataGridSortCommandEventArgs)

End Sub

Thanks

.

.
 
K

Ken Cox [Microsoft MVP]

If the textbox hasn't been reconstituted at that point, you won't be able to
get anything from it. Technically, it doesn't exist on the page yet.

SK said:
But I dont want to enter this code in the sort event. it
should call the test function via the onitemcreated event.

-----Original Message-----
Yes, if you add a handler:

Sub Sort(ByVal sender As Object, _
ByVal e As DataGridSortCommandEventArgs)
Response.Write("Sort:" & TextBox1.Text)
End Sub

<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server"
allowsorting="True"></asp:datagrid>
<p> </p>
<p>
<asp:textbox id="TextBox1"
runat="server"> said:
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
</form>


Hi Ken,

does it work for you even if you click the header in
the datagrid ?

THanks


-----Original Message-----
Hi,

I'm not able to reproduce your problem. The following
code outputs the
contents of the textbox in the response.write.

Ken
Microsoft MVP [ASP.NET]


<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1"
runat="server"></asp:datagrid>
<p> </p>
<p>
<asp:textbox id="TextBox1"
runat="server"></asp:textbox></p>
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
</form>

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim arList As New ArrayList
arList.Add("1")
arList.Add("2")
arList.Add("3")

DataGrid1.DataSource = arList
DataGrid1.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Write(TextBox1.Text)
End Sub

Public Function test()
Response.Write("testme" & TextBox1.Text)
End Function

Private Sub DataGrid1_OnItemCreated(ByVal sender As
Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Header
test()
End Select
End Sub

Sub Sort(ByVal sender As Object, ByVal e As
DataGridSortCommandEventArgs)

End Sub

message
Hello,

I have a datagrid, textbox and a button in my page. The
datagtrid
has sorting enabled. But, I am not doing any sorting.
Its
just for
test purpose. Now the user enteres some text in the
textbox and
presses the button and it response.writes the value of
it.
Now when I
do a sort then the OnItemCreated Method is called, which
again calls
the test function, but it doesnt print the data from the
textbox. It
behaves like the textbox is empy, but it isnt. I can see
the value in
the textbox. I dont understand that all. Can somebody
help
out?

Here is the code:

Private Sub Page_Load(ByVal sender As System.Object,
ByVal
e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim arList As New ArrayList
arList.Add("1")
arList.Add("2")
arList.Add("3")

DataGrid1.DataSource = arList
DataGrid1.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Response.Write(TextBox1.Text)
End Sub

Public Function test()
Response.Write("testme" & TextBox1.Text)
End Function

Private Sub DataGrid1_OnItemCreated(ByVal sender As
Object, ByVal
e As System.Web.UI.WebControls.DataGridItemEventArgs)
Handles
DataGrid1.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Header
test()
End Select
End Sub

Sub Sort(ByVal sender As Object, ByVal e As
DataGridSortCommandEventArgs)

End Sub

Thanks

.

.
 
S

SK

So the OnItemCreated is called before the textbox is
created?

Thanks

-----Original Message-----
If the textbox hasn't been reconstituted at that point, you won't be able to
get anything from it. Technically, it doesn't exist on the page yet.

But I dont want to enter this code in the sort event. it
should call the test function via the onitemcreated event.

-----Original Message-----
Yes, if you add a handler:

Sub Sort(ByVal sender As Object, _
ByVal e As DataGridSortCommandEventArgs)
Response.Write("Sort:" & TextBox1.Text)
End Sub

<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server"
allowsorting="True"></asp:datagrid>
<p> </p>
<p>
<asp:textbox id="TextBox1"
runat="server"> said:
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
</form>


Hi Ken,

does it work for you even if you click the header in
the datagrid ?

THanks


-----Original Message-----
Hi,

I'm not able to reproduce your problem. The following
code outputs the
contents of the textbox in the response.write.

Ken
Microsoft MVP [ASP.NET]


<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1"
runat="server"></asp:datagrid>
<p> </p>
<p>
<asp:textbox id="TextBox1"
runat="server"></asp:textbox></p>
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
</form>

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim arList As New ArrayList
arList.Add("1")
arList.Add("2")
arList.Add("3")

DataGrid1.DataSource = arList
DataGrid1.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Write(TextBox1.Text)
End Sub

Public Function test()
Response.Write("testme" & TextBox1.Text)
End Function

Private Sub DataGrid1_OnItemCreated(ByVal sender As
Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Header
test()
End Select
End Sub

Sub Sort(ByVal sender As Object, ByVal e As
DataGridSortCommandEventArgs)

End Sub

message
Hello,

I have a datagrid, textbox and a button in my page. The
datagtrid
has sorting enabled. But, I am not doing any sorting.
Its
just for
test purpose. Now the user enteres some text in the
textbox and
presses the button and it response.writes the value of
it.
Now when I
do a sort then the OnItemCreated Method is called, which
again calls
the test function, but it doesnt print the data from the
textbox. It
behaves like the textbox is empy, but it isnt. I can see
the value in
the textbox. I dont understand that all. Can somebody
help
out?

Here is the code:

Private Sub Page_Load(ByVal sender As System.Object,
ByVal
e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim arList As New ArrayList
arList.Add("1")
arList.Add("2")
arList.Add("3")

DataGrid1.DataSource = arList
DataGrid1.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Response.Write(TextBox1.Text)
End Sub

Public Function test()
Response.Write("testme" & TextBox1.Text)
End Function

Private Sub DataGrid1_OnItemCreated(ByVal sender As
Object, ByVal
e As System.Web.UI.WebControls.DataGridItemEventArgs)
Handles
DataGrid1.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Header
test()
End Select
End Sub

Sub Sort(ByVal sender As Object, ByVal e As
DataGridSortCommandEventArgs)

End Sub

Thanks

.


.

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top