Groups | Blog | Home
all groups > asp.net datagrid control > september 2007 >

asp.net datagrid control : How to retrive value that is invisible in gridview



Eliyahu Goldin
9/5/2007 12:00:00 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


[quoted text, click to view]

phyumon thant
9/5/2007 12:08:18 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!





Ross Culver
9/5/2007 1:56:58 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


[quoted text, click to view]

Ike Ellis
9/11/2007 10:58:46 AM
Fantastic, Eliyahu. Of all the solutions to this problem, I think this is
the best.

"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@mMvVpPsS.org> wrote in
message news:OMpmZ647HHA.4436@TK2MSFTNGP03.phx.gbl...
[quoted text, click to view]

10/8/2007 8:48:04 AM
On Sep 5, 3:30 am, "Eliyahu Goldin"
[quoted text, click to view]

I have tried five different approaches to this problem and this is the
best solution out there. Thanks Eliyahu !
Shane Jones
10/23/2007 3:31:45 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@mMvVpPsS.org> wrote in
message news:OMpmZ647HHA.4436@TK2MSFTNGP03.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button