Hi !
I need to embed a text box in a footer of a GridView's boundfield
column to get data prior to a row insert.
The textbox is usable and showing up in the web page source using View
Source, but I cannot see it using an alert,
or after postback on the server side (code behind). Is there a way to
reference such a control (embedded HTML in footertext) ?
If so, please advise ! (I embedded buttons in the command column which
work and execute their click events ok)
this code builds the footertext:
Dim grdBF As BoundField = New BoundField
grdBF.DataField = colNamesArray(i dx)
'tbox
If colIsEditableAr ray(idx) = "false" Then grdBF.ReadOnly = True
'todo: style: grdBF.ApplyForm atInEditMode = True
'this always puts a textbox in if editable, todo: chg to add some
input control per type:
stCtrl = _
"<input id=""" & colNamesArray(i dx) & "textbox"" Type=""Text""
size=""20"" maxlength=""30" " value="""">test </input>"
If colIsEditableAr ray(idx) = "true" Then grdBF.FooterTex t = stCtrl
dataGridView.Co lumns.Add(grdBF )
''''''''''''''' ''''''''''''''' ''''''''
this code tries to access after postback, server side, but does not
work, fix needed:
Dim tb As HtmlInputText =
dataGridView.Fo oterRow.FindCon trol(colNamesAr ray(idx) & "textbox")
''''''''''''''' ''''''''''''''' ''''''
This code tries to show it client-side, at click event, before the
postback-submit:
(we can show only the innertext)
var state1 = document.getEle mentById("txtSt ate");
var deForm = document.getEle mentById("form1 ");
state1.value = "insertclic ked" //indicate state
//debug:
var tb = document.getEle mentById("dataG ridView");
var i,j;
var msg;
for(i=0; i<tb.rows.lengt h;i++)
{
msg += "\r\n" + tb.rows[i].cells[2].innerText;
}
alert(msg);
deForm.submit() //postback to server to save the data only
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
the fix must be server side in code behind, since this all must be
completely dynamic, and is dependent on a config file to get its table
data from a sqldatasource which requires the boundfields in this
gridview. fyi my templatefield columns all work fine, getting the data
back in the request object since its otherwise blown away by a
postback.
Regards !
Don
-------------------------------------------
Don Collier, Senior Developer
Web Site: http://doncollier.clickhere2.net