HighTechTalks DotNet Forums  

How to retrive value that is invisible in gridview

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss How to retrive value that is invisible in gridview in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
phyumon thant
 
Posts: n/a

Default How to retrive value that is invisible in gridview - 09-05-2007 , 02:08 AM








I can retrieve the value from gridview but i cann't if the value is
invisible in gridview. If i read the value that is hidden i got the
value null. I don't know why. if someone know, please let me know.

my code is as follow

protected void GridView3_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
int a = GridView3.EditIndex;

Control ctl = GridView3.Rows[a].Controls[0];
string value =
((System.Web.UI.WebControls.TextBox)(ctl.Controls[1])).Text;

Control ctl1 = GridView3.Rows[a].Controls[1];
string value1 =
((System.Web.UI.WebControls.TextBox)(ctl1.Controls [1])).Text;

Control ctl2 = GridView3.Rows[a].Controls[3];
string value2 =
((System.Web.UI.WebControls.TextBox)(ctl2.Controls [1])).Text;


}

i got value and value1 but didn't get value2 because i make it invisible
in gridview. i want to have this. please help me.

Thanks a lot!





*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #2  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: How to retrive value that is invisible in gridview - 09-05-2007 , 02:30 AM






Server controls with Visible=false don't get rendered to client and don't
come back in postbacks. That's why you can't retrieve them. Leave
Visible=true and hide the control with a css rule display:none.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"phyumon thant" <phyumon (AT) gmail (DOT) com> wrote

Quote:

I can retrieve the value from gridview but i cann't if the value is
invisible in gridview. If i read the value that is hidden i got the
value null. I don't know why. if someone know, please let me know.

my code is as follow

protected void GridView3_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
int a = GridView3.EditIndex;

Control ctl = GridView3.Rows[a].Controls[0];
string value =
((System.Web.UI.WebControls.TextBox)(ctl.Controls[1])).Text;

Control ctl1 = GridView3.Rows[a].Controls[1];
string value1 =
((System.Web.UI.WebControls.TextBox)(ctl1.Controls [1])).Text;

Control ctl2 = GridView3.Rows[a].Controls[3];
string value2 =
((System.Web.UI.WebControls.TextBox)(ctl2.Controls [1])).Text;


}

i got value and value1 but didn't get value2 because i make it invisible
in gridview. i want to have this. please help me.

Thanks a lot!





*** Sent via Developersdex http://www.developersdex.com ***



Reply With Quote
  #3  
Old   
Ross Culver
 
Posts: n/a

Default Re: How to retrive value that is invisible in gridview - 09-05-2007 , 01:56 PM



Rather than 'hiding' your values using formatting, use the zero-based
dataview datakeynames properties. Set the applicable columns in your
datakeynames then retreave their values using the following, probably in the
dataview's selectedindexchanged event:
Me.gridview1.SelectedDataKey.Item(0).ToString

Ross


"phyumon thant" <phyumon (AT) gmail (DOT) com> wrote

Quote:

I can retrieve the value from gridview but i cann't if the value is
invisible in gridview. If i read the value that is hidden i got the
value null. I don't know why. if someone know, please let me know.

my code is as follow

protected void GridView3_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
int a = GridView3.EditIndex;

Control ctl = GridView3.Rows[a].Controls[0];
string value =
((System.Web.UI.WebControls.TextBox)(ctl.Controls[1])).Text;

Control ctl1 = GridView3.Rows[a].Controls[1];
string value1 =
((System.Web.UI.WebControls.TextBox)(ctl1.Controls [1])).Text;

Control ctl2 = GridView3.Rows[a].Controls[3];
string value2 =
((System.Web.UI.WebControls.TextBox)(ctl2.Controls [1])).Text;


}

i got value and value1 but didn't get value2 because i make it invisible
in gridview. i want to have this. please help me.

Thanks a lot!





*** Sent via Developersdex http://www.developersdex.com ***



Reply With Quote
  #4  
Old   
Ike Ellis
 
Posts: n/a

Default Re: How to retrive value that is invisible in gridview - 09-11-2007 , 12:58 PM



Fantastic, Eliyahu. Of all the solutions to this problem, I think this is
the best.

"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN (AT) mMvVpPsS (DOT) org> wrote in
message news:OMpmZ647HHA.4436 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
Quote:
Server controls with Visible=false don't get rendered to client and don't
come back in postbacks. That's why you can't retrieve them. Leave
Visible=true and hide the control with a css rule display:none.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"phyumon thant" <phyumon (AT) gmail (DOT) com> wrote in message
news:OQTYKu47HHA.1900 (AT) TK2MSFTNGP02 (DOT) phx.gbl...


I can retrieve the value from gridview but i cann't if the value is
invisible in gridview. If i read the value that is hidden i got the
value null. I don't know why. if someone know, please let me know.

my code is as follow

protected void GridView3_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
int a = GridView3.EditIndex;

Control ctl = GridView3.Rows[a].Controls[0];
string value =
((System.Web.UI.WebControls.TextBox)(ctl.Controls[1])).Text;

Control ctl1 = GridView3.Rows[a].Controls[1];
string value1 =
((System.Web.UI.WebControls.TextBox)(ctl1.Controls [1])).Text;

Control ctl2 = GridView3.Rows[a].Controls[3];
string value2 =
((System.Web.UI.WebControls.TextBox)(ctl2.Controls [1])).Text;


}

i got value and value1 but didn't get value2 because i make it invisible
in gridview. i want to have this. please help me.

Thanks a lot!





*** Sent via Developersdex http://www.developersdex.com ***




Reply With Quote
  #5  
Old   
rod-tech@adelphia.net
 
Posts: n/a

Default Re: How to retrive value that is invisible in gridview - 10-08-2007 , 10:48 AM



On Sep 5, 3:30 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD... (AT) mMvVpPsS (DOT) org> wrote:
Quote:
Server controls with Visible=false don't get rendered to client and don't
come back in postbacks. That's why you can't retrieve them. Leave
Visible=true and hide the control with a css rule display:none.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

"phyumon thant" <phyu... (AT) gmail (DOT) com> wrote in message

news:OQTYKu47HHA.1900 (AT) TK2MSFTNGP02 (DOT) phx.gbl...





I can retrieve the value from gridview but i cann't if the value is
invisible in gridview. If i read the value that is hidden i got the
value null. I don't know why. if someone know, please let me know.

my code is as follow

protected void GridView3_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
int a = GridView3.EditIndex;

Control ctl = GridView3.Rows[a].Controls[0];
string value =
((System.Web.UI.WebControls.TextBox)(ctl.Controls[1])).Text;

Control ctl1 = GridView3.Rows[a].Controls[1];
string value1 =
((System.Web.UI.WebControls.TextBox)(ctl1.Controls [1])).Text;

Control ctl2 = GridView3.Rows[a].Controls[3];
string value2 =
((System.Web.UI.WebControls.TextBox)(ctl2.Controls [1])).Text;

}

i got value and value1 but didn't get value2 because i make it invisible
in gridview. i want to have this. please help me.

Thanks a lot!

*** Sent via Developersdexhttp://www.developersdex.com***- Hide quoted text -

- Show quoted text -
I have tried five different approaches to this problem and this is the
best solution out there. Thanks Eliyahu !



Reply With Quote
  #6  
Old   
Shane Jones
 
Posts: n/a

Default Re: How to retrive value that is invisible in gridview - 10-23-2007 , 03:31 PM



Eliyahn -- I have a SQL Sever table that includes Client Data -- I created
an AJAXenabled Web Site with a TextBoxSSN, a SQLDataSource, and an
ASPxGridView (from DevExpress). In my Select Query, I've included a WHERE
Clause (WHERE (SSN = @SSN) and the following Parameter: SSN =
TextBoxSSN.Text

SSN is a PrimaryKey in my SQL Server table. I have set Visible option for
the SSN field to FALSE (to comply with HIPPA guidelines), but when I do
this, I'm not able to UPDATE or DELETE records. How can I ADD, UPDATE,
DELETE records in the SQL Server table without showing the SSN field?

I read your post about setting Visible=True, and hidding the control with a
css rule display none -- where do I create this css rule?

Thanks in advance for your (or anyone else's) assistance on this.

WebGuy

Here's my SELECT Statement

SELECT SSN, MaskedSSN, LAST_NAME, FIRST_NAME, MI, DOB, STREET_1, CITY_1,
STATE_1, ZIP_1, ACTIVE_ADDR, STREET_2, CITY_2, STATE_2, ZIP_2, PHONE_1,
PHONE_2, MOBILE_PHONE, EMAIL_1, EMAIL_2
FROM tblClient WHERE (SSN = @SSN)

===============================================
"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN (AT) mMvVpPsS (DOT) org> wrote in
message news:OMpmZ647HHA.4436 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
Quote:
Server controls with Visible=false don't get rendered to client and don't
come back in postbacks. That's why you can't retrieve them. Leave
Visible=true and hide the control with a css rule display:none.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"phyumon thant" <phyumon (AT) gmail (DOT) com> wrote in message
news:OQTYKu47HHA.1900 (AT) TK2MSFTNGP02 (DOT) phx.gbl...


I can retrieve the value from gridview but i cann't if the value is
invisible in gridview. If i read the value that is hidden i got the
value null. I don't know why. if someone know, please let me know.

my code is as follow

protected void GridView3_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
int a = GridView3.EditIndex;

Control ctl = GridView3.Rows[a].Controls[0];
string value =
((System.Web.UI.WebControls.TextBox)(ctl.Controls[1])).Text;

Control ctl1 = GridView3.Rows[a].Controls[1];
string value1 =
((System.Web.UI.WebControls.TextBox)(ctl1.Controls [1])).Text;

Control ctl2 = GridView3.Rows[a].Controls[3];
string value2 =
((System.Web.UI.WebControls.TextBox)(ctl2.Controls [1])).Text;


}

i got value and value1 but didn't get value2 because i make it invisible
in gridview. i want to have this. please help me.

Thanks a lot!





*** Sent via Developersdex http://www.developersdex.com ***





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.