469,922 Members | 1,938 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,922 developers. It's quick & easy.

Getting value from FormView

BB
Hi,
I am using FormView Contol, TextBox (Hidden ) and Submit button
whose caption is "View Page" in my aspx page.
Here is what I am tryin to do.When page loads I generate dynamic
url in text box . I want to append exisitng value in Formview field
"CustomeID" to url. When userclicks on "view page" ,new window is
opened with dynamic url.

I am able to do generarting url dynamically, but dont know how i can
do rest of the things. Any idea?

<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
CellPadding="4" DataKeyNames="CustomerID"
DataSourceID="AccessDataSource1" ForeColor="#333333"
OnDataBound="FormView1_DataBound">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#C0FFC0" />
<EditItemTemplate>
<table>
<tr>
<td style="width: 344px">
<span style="font-size:
9pt"><strong>ID:</strong></span></td>
<td colspan="2">
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("CustomerID") %>' Font-Names="Arial"
Font-Size="8pt"></asp:Label></td>
</tr>
<tr>.....

How I can get value of "IDLabel1" may be in page load or
databound event of page? so that I can concanate value of IDLabel1 to
my url
Thank you

Aug 25 '06 #1
8 6700
KJ
After you have databound the fomview, using the following style of
coding to get the value of IDLabel1:

Label IDLabel1 = (Label)FormView1.FindControl("FormView1");
string MyValue = IDLabel1.Text;

BB wrote:
Hi,
I am using FormView Contol, TextBox (Hidden ) and Submit button
whose caption is "View Page" in my aspx page.
Here is what I am tryin to do.When page loads I generate dynamic
url in text box . I want to append exisitng value in Formview field
"CustomeID" to url. When userclicks on "view page" ,new window is
opened with dynamic url.

I am able to do generarting url dynamically, but dont know how i can
do rest of the things. Any idea?

<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
CellPadding="4" DataKeyNames="CustomerID"
DataSourceID="AccessDataSource1" ForeColor="#333333"
OnDataBound="FormView1_DataBound">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#C0FFC0" />
<EditItemTemplate>
<table>
<tr>
<td style="width: 344px">
<span style="font-size:
9pt"><strong>ID:</strong></span></td>
<td colspan="2">
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("CustomerID") %>' Font-Names="Arial"
Font-Size="8pt"></asp:Label></td>
</tr>
<tr>.....

How I can get value of "IDLabel1" may be in page load or
databound event of page? so that I can concanate value of IDLabel1 to
my url
Thank you
Aug 29 '06 #2
KJ
Sorry, I screwed up the first code line, it should be:

Label IDLabel1 = (Label)FormView1.FindControl("IDLabel1");

BB wrote:
Hi,
I am using FormView Contol, TextBox (Hidden ) and Submit button
whose caption is "View Page" in my aspx page.
Here is what I am tryin to do.When page loads I generate dynamic
url in text box . I want to append exisitng value in Formview field
"CustomeID" to url. When userclicks on "view page" ,new window is
opened with dynamic url.

I am able to do generarting url dynamically, but dont know how i can
do rest of the things. Any idea?

<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
CellPadding="4" DataKeyNames="CustomerID"
DataSourceID="AccessDataSource1" ForeColor="#333333"
OnDataBound="FormView1_DataBound">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#C0FFC0" />
<EditItemTemplate>
<table>
<tr>
<td style="width: 344px">
<span style="font-size:
9pt"><strong>ID:</strong></span></td>
<td colspan="2">
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("CustomerID") %>' Font-Names="Arial"
Font-Size="8pt"></asp:Label></td>
</tr>
<tr>.....

How I can get value of "IDLabel1" may be in page load or
databound event of page? so that I can concanate value of IDLabel1 to
my url
Thank you
Aug 29 '06 #3
BB
Hi,

Thank you for your response. Here is what I did...

Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim sLabel As WebControls.Label

sLabel = FormView1.FindControl("IDLabel1")
TextBox1.Text = TextBox1.Text & sLabel.Text
End Sub

I get following error...Any Idea?

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

Line 19: sLabel = FormView1.FindControl("IDLabel1")
Line 20: TextBox1.Text = TextBox1.Text & sLabel.Text
Line 21: End Sub
Line 22: </script>
Thamk you

"KJ" <n_**********@mail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Sorry, I screwed up the first code line, it should be:

Label IDLabel1 = (Label)FormView1.FindControl("IDLabel1");

BB wrote:
>Hi,
I am using FormView Contol, TextBox (Hidden ) and Submit button
whose caption is "View Page" in my aspx page.
Here is what I am tryin to do.When page loads I generate dynamic
url in text box . I want to append exisitng value in Formview field
"CustomeID" to url. When userclicks on "view page" ,new window is
opened with dynamic url.

I am able to do generarting url dynamically, but dont know how i can
do rest of the things. Any idea?

<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
CellPadding="4" DataKeyNames="CustomerID"
DataSourceID="AccessDataSource1" ForeColor="#333333"
OnDataBound="FormView1_DataBound">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#C0FFC0" />
<EditItemTemplate>
<table>
<tr>
<td style="width: 344px">
<span style="font-size:
9pt"><strong>ID:</strong></span></td>
<td colspan="2">
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("CustomerID") %>' Font-Names="Arial"
Font-Size="8pt"></asp:Label></td>
</tr>
<tr>.....

How I can get value of "IDLabel1" may be in page load or
databound event of page? so that I can concanate value of IDLabel1 to
my url
Thank you

Aug 29 '06 #4
KJ
Now I see.

In the DataBound method, you can use the Row property of FormView1 to
programmatically access the FormViewRow object that represents the
current data row.

The data row contains different content based on the template that is
rendered for the current mode (specified by the CurrentMode property).

You can only access the contents of the template for the current mode.
This means that you will only be able to find IDLabel1 using this
technique if the FormView1 is in Edit mode (e.g., using the
EditItemTemplate containing IDLabel1).

Check FormView1.CurrentMode and see what you come up with. If the value
is not FormViewMode.Edit, you cannot get the IDLabel1.
BB wrote:
Hi,

Thank you for your response. Here is what I did...

Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim sLabel As WebControls.Label

sLabel = FormView1.FindControl("IDLabel1")
TextBox1.Text = TextBox1.Text & sLabel.Text
End Sub

I get following error...Any Idea?

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

Line 19: sLabel = FormView1.FindControl("IDLabel1")
Line 20: TextBox1.Text = TextBox1.Text & sLabel.Text
Line 21: End Sub
Line 22: </script>
Thamk you

"KJ" <n_**********@mail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Sorry, I screwed up the first code line, it should be:

Label IDLabel1 = (Label)FormView1.FindControl("IDLabel1");

BB wrote:
Hi,
I am using FormView Contol, TextBox (Hidden ) and Submit button
whose caption is "View Page" in my aspx page.
Here is what I am tryin to do.When page loads I generate dynamic
url in text box . I want to append exisitng value in Formview field
"CustomeID" to url. When userclicks on "view page" ,new window is
opened with dynamic url.

I am able to do generarting url dynamically, but dont know how i can
do rest of the things. Any idea?

<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
CellPadding="4" DataKeyNames="CustomerID"
DataSourceID="AccessDataSource1" ForeColor="#333333"
OnDataBound="FormView1_DataBound">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#C0FFC0" />
<EditItemTemplate>
<table>
<tr>
<td style="width: 344px">
<span style="font-size:
9pt"><strong>ID:</strong></span></td>
<td colspan="2">
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("CustomerID") %>' Font-Names="Arial"
Font-Size="8pt"></asp:Label></td>
</tr>
<tr>.....

How I can get value of "IDLabel1" may be in page load or
databound event of page? so that I can concanate value of IDLabel1 to
my url
Thank you
Aug 29 '06 #5
BB
Well...Logic behind this is ...
When page is loaded I create link in text box which is invisible. I
have "Preview" button when user click it , It takes url from invisible text
box and goes to that link. Now when form is loaded. IDLabel1 value is
already there displayed. I just need to take that vale and pass as
querystring. ..like ...?iGroup=IDLabel1.text
User interface will be...
User open this form. Selects record to edit using previous next
link buttons on FormView.then Click edit . Make necessary changes. Save
changes. and click on "Preview" button.

Any idea how I acheive this?

"KJ" <n_**********@mail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Now I see.

In the DataBound method, you can use the Row property of FormView1 to
programmatically access the FormViewRow object that represents the
current data row.

The data row contains different content based on the template that is
rendered for the current mode (specified by the CurrentMode property).

You can only access the contents of the template for the current mode.
This means that you will only be able to find IDLabel1 using this
technique if the FormView1 is in Edit mode (e.g., using the
EditItemTemplate containing IDLabel1).

Check FormView1.CurrentMode and see what you come up with. If the value
is not FormViewMode.Edit, you cannot get the IDLabel1.
BB wrote:
>Hi,

Thank you for your response. Here is what I did...

Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim sLabel As WebControls.Label

sLabel = FormView1.FindControl("IDLabel1")
TextBox1.Text = TextBox1.Text & sLabel.Text
End Sub

I get following error...Any Idea?

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set
to an instance of an object.

Source Error:

Line 19: sLabel = FormView1.FindControl("IDLabel1")
Line 20: TextBox1.Text = TextBox1.Text & sLabel.Text
Line 21: End Sub
Line 22: </script>
Thamk you

"KJ" <n_**********@mail.comwrote in message
news:11**********************@p79g2000cwp.googleg roups.com...
Sorry, I screwed up the first code line, it should be:

Label IDLabel1 = (Label)FormView1.FindControl("IDLabel1");

BB wrote:
Hi,
I am using FormView Contol, TextBox (Hidden ) and Submit button
whose caption is "View Page" in my aspx page.
Here is what I am tryin to do.When page loads I generate dynamic
url in text box . I want to append exisitng value in Formview field
"CustomeID" to url. When userclicks on "view page" ,new window is
opened with dynamic url.

I am able to do generarting url dynamically, but dont know how i
can
do rest of the things. Any idea?

<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
CellPadding="4" DataKeyNames="CustomerID"
DataSourceID="AccessDataSource1" ForeColor="#333333"
OnDataBound="FormView1_DataBound">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#C0FFC0" />
<EditItemTemplate>
<table>
<tr>
<td style="width: 344px">
<span style="font-size:
9pt"><strong>ID:</strong></span></td>
<td colspan="2">
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("CustomerID") %>' Font-Names="Arial"
Font-Size="8pt"></asp:Label></td>
</tr>
<tr>.....

How I can get value of "IDLabel1" may be in page load
or
databound event of page? so that I can concanate value of IDLabel1 to
my url
Thank you

Aug 29 '06 #6
KJ
I'm a little confused: are you saying that the value of IDLabel1 is
never changed by the user?

BB wrote:
Well...Logic behind this is ...
When page is loaded I create link in text box which is invisible. I
have "Preview" button when user click it , It takes url from invisible text
box and goes to that link. Now when form is loaded. IDLabel1 value is
already there displayed. I just need to take that vale and pass as
querystring. ..like ...?iGroup=IDLabel1.text
User interface will be...
User open this form. Selects record to edit using previous next
link buttons on FormView.then Click edit . Make necessary changes. Save
changes. and click on "Preview" button.

Any idea how I acheive this?

"KJ" <n_**********@mail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Now I see.

In the DataBound method, you can use the Row property of FormView1 to
programmatically access the FormViewRow object that represents the
current data row.

The data row contains different content based on the template that is
rendered for the current mode (specified by the CurrentMode property).

You can only access the contents of the template for the current mode.
This means that you will only be able to find IDLabel1 using this
technique if the FormView1 is in Edit mode (e.g., using the
EditItemTemplate containing IDLabel1).

Check FormView1.CurrentMode and see what you come up with. If the value
is not FormViewMode.Edit, you cannot get the IDLabel1.
BB wrote:
Hi,

Thank you for your response. Here is what I did...

Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim sLabel As WebControls.Label

sLabel = FormView1.FindControl("IDLabel1")
TextBox1.Text = TextBox1.Text & sLabel.Text
End Sub

I get following error...Any Idea?

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set
to an instance of an object.

Source Error:

Line 19: sLabel = FormView1.FindControl("IDLabel1")
Line 20: TextBox1.Text = TextBox1.Text & sLabel.Text
Line 21: End Sub
Line 22: </script>
Thamk you

"KJ" <n_**********@mail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Sorry, I screwed up the first code line, it should be:

Label IDLabel1 = (Label)FormView1.FindControl("IDLabel1");

BB wrote:
Hi,
I am using FormView Contol, TextBox (Hidden ) and Submit button
whose caption is "View Page" in my aspx page.
Here is what I am tryin to do.When page loads I generate dynamic
url in text box . I want to append exisitng value in Formview field
"CustomeID" to url. When userclicks on "view page" ,new window is
opened with dynamic url.

I am able to do generarting url dynamically, but dont know how i
can
do rest of the things. Any idea?

<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
CellPadding="4" DataKeyNames="CustomerID"
DataSourceID="AccessDataSource1" ForeColor="#333333"
OnDataBound="FormView1_DataBound">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#C0FFC0" />
<EditItemTemplate>
<table>
<tr>
<td style="width: 344px">
<span style="font-size:
9pt"><strong>ID:</strong></span></td>
<td colspan="2">
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("CustomerID") %>' Font-Names="Arial"
Font-Size="8pt"></asp:Label></td>
</tr>
<tr>.....

How I can get value of "IDLabel1" may be in page load
or
databound event of page? so that I can concanate value of IDLabel1 to
my url
Thank you
Aug 31 '06 #7
BB
Yes..Since its a label. User cannot change value. He can edit other fields
but not IDLabel1..
"KJ" <n_**********@mail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
I'm a little confused: are you saying that the value of IDLabel1 is
never changed by the user?

BB wrote:
>Well...Logic behind this is ...
When page is loaded I create link in text box which is
invisible. I
have "Preview" button when user click it , It takes url from invisible
text
box and goes to that link. Now when form is loaded. IDLabel1 value is
already there displayed. I just need to take that vale and pass as
querystring. ..like ...?iGroup=IDLabel1.text
User interface will be...
User open this form. Selects record to edit using previous next
link buttons on FormView.then Click edit . Make necessary changes. Save
changes. and click on "Preview" button.

Any idea how I acheive this?

"KJ" <n_**********@mail.comwrote in message
news:11**********************@h48g2000cwc.googleg roups.com...
Now I see.

In the DataBound method, you can use the Row property of FormView1 to
programmatically access the FormViewRow object that represents the
current data row.

The data row contains different content based on the template that is
rendered for the current mode (specified by the CurrentMode property).

You can only access the contents of the template for the current mode.
This means that you will only be able to find IDLabel1 using this
technique if the FormView1 is in Edit mode (e.g., using the
EditItemTemplate containing IDLabel1).

Check FormView1.CurrentMode and see what you come up with. If the value
is not FormViewMode.Edit, you cannot get the IDLabel1.
BB wrote:
Hi,

Thank you for your response. Here is what I did...

Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim sLabel As WebControls.Label

sLabel = FormView1.FindControl("IDLabel1")
TextBox1.Text = TextBox1.Text & sLabel.Text
End Sub

I get following error...Any Idea?

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the
current web request. Please review the stack trace for more
information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set
to an instance of an object.

Source Error:

Line 19: sLabel = FormView1.FindControl("IDLabel1")
Line 20: TextBox1.Text = TextBox1.Text & sLabel.Text
Line 21: End Sub
Line 22: </script>
Thamk you

"KJ" <n_**********@mail.comwrote in message
news:11**********************@p79g2000cwp.googleg roups.com...
Sorry, I screwed up the first code line, it should be:

Label IDLabel1 = (Label)FormView1.FindControl("IDLabel1");

BB wrote:
Hi,
I am using FormView Contol, TextBox (Hidden ) and Submit
button
whose caption is "View Page" in my aspx page.
Here is what I am tryin to do.When page loads I generate
dynamic
url in text box . I want to append exisitng value in Formview field
"CustomeID" to url. When userclicks on "view page" ,new window is
opened with dynamic url.

I am able to do generarting url dynamically, but dont know how i
can
do rest of the things. Any idea?

<asp:FormView ID="FormView1" runat="server"
AllowPaging="True"
CellPadding="4" DataKeyNames="CustomerID"
DataSourceID="AccessDataSource1" ForeColor="#333333"
OnDataBound="FormView1_DataBound">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#C0FFC0" />
<EditItemTemplate>
<table>
<tr>
<td style="width: 344px">
<span style="font-size:
9pt"><strong>ID:</strong></span></td>
<td colspan="2">
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("CustomerID") %>' Font-Names="Arial"
Font-Size="8pt"></asp:Label></td>
</tr>
<tr>.....

How I can get value of "IDLabel1" may be in page
load
or
databound event of page? so that I can concanate value of IDLabel1
to
my url
Thank you


Aug 31 '06 #8
Bob
Any ideas guys?
"BB" <sh******@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
Hi,
I am using FormView Contol, TextBox (Hidden ) and Submit button
whose caption is "View Page" in my aspx page.
Here is what I am tryin to do.When page loads I generate dynamic
url in text box . I want to append exisitng value in Formview field
"CustomeID" to url. When userclicks on "view page" ,new window is
opened with dynamic url.

I am able to do generarting url dynamically, but dont know how i can
do rest of the things. Any idea?

<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
CellPadding="4" DataKeyNames="CustomerID"
DataSourceID="AccessDataSource1" ForeColor="#333333"
OnDataBound="FormView1_DataBound">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#C0FFC0" />
<EditItemTemplate>
<table>
<tr>
<td style="width: 344px">
<span style="font-size:
9pt"><strong>ID:</strong></span></td>
<td colspan="2">
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("CustomerID") %>' Font-Names="Arial"
Font-Size="8pt"></asp:Label></td>
</tr>
<tr>.....

How I can get value of "IDLabel1" may be in page load or
databound event of page? so that I can concanate value of IDLabel1 to
my url
Thank you

Sep 10 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by abillmeier | last post: by
2 posts views Thread by Hugh | last post: by
1 post views Thread by user | last post: by
reply views Thread by =?Utf-8?B?UmJydA==?= | last post: by
reply views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.