How to access datagrid template column textbox text in

I just want to access text from datagrid template column textbox,any one who knows solutions or suggestions(through codes), pls share it.Thanks in advance.

1/24/2008 11:24:27 AM 72751 articles. 3 followers. Follow

7 Replies

Similar Articles

[PageSpeed] 27

 to access text from template column textbox... use FindControl() method... for Ex.,

Label1.Text = ((TextBox)GridView1.Rows[0].Cell[0].FindControl("txtTextBox")).Text; //assuming that First Column; cells[0] is the TextBox Column... the code will retrieve text from first column textbox of the first row and assign to label...

you can refer to this link also.. 

Control.FindControl Method (String) (System.Web.UI)



in vb: Label1.Text = (CType(GridView1.Rows(0).Cell(0).FindControl("txtTextBox"), TextBox)).Text 


hope it helps./. 

[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"

Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
1/24/2008 11:46:33 AM

I just want to access text from datagrid template column textbox,any one who knows solutions or suggestions(through codes),

You can use findcotnrol method.

for example

Dim txtValue as string=CType(DataGrid1.Items(index).FindControl("TextBoxID"),TextBox).Text


Click on 'Mark as Answer' if this post is helpful.

ImranKhan pathan
1/24/2008 12:03:20 PM


I apologise, what i wanted is actually,

In Datagrid template column cell from which i want to access text has a textbox as well as a button in same cell(for browsing and selecting a file whose path will be displayed in the textbox) and its control id is inputfile.

But i want to access only filename(viz.not whole path) from textbox and store it in database.

Your code would have definitely worked for a template column having only textbox in the cell.

For my above requirement, if u have any solution or suggestion,then pls share it.Thanks in advance. 


1/24/2008 12:44:31 PM


The template name is uploadedFile(not input file).I want to access file name alone from the textbox and not the whole path.Pls reply asap.Thanks.
1/24/2008 1:13:54 PM


are u using file upload control?

if yes then
Here are some useful properties:-

FileUpload1.FileName :- Will give File Name with the full Path.
FileUpload1.PostedFile.FileName :- Will give only the file name.
FileUpload1.PostedFile.ContentLength :- will give size of the file in Bytes.
FileUpload1.PostedFile.ContentType :- will give MIME type of uploaded file, i.e. "image/gif".

(Assuming the Control ID Name is FileUpload1)


Virendra (MCTS)

My SiteBlog
1/24/2008 1:20:03 PM

I want to access file name alone from the textbox and not the whole path.

to get the filename, 

string strFullPath = CType(GridView1.Rows(0).Cell(0).FindControl("txtTextBox"), TextBox).Text

string strFileName =  strFullPath.SubString(strFullPath.LastIndexOf("\") + 1)

[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"

Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
1/24/2008 1:21:21 PM

 Check this 


"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
1/24/2008 1:27:45 PM

Similar Artilces:

how to set the text of a textbox template in a grid view
I want to know how to set the control of a cell to a certain number after the view has been loaded and binded to the data.  I have a gridview that populates from a database table, the last colume in the view is a textbox which is a template that is not bound to any data. I want to be able to set the vale of that textbox for a row when a user clicks on a button.  Right now i have a textbox that you type a number value into and when you hit process it takes that number and makes payments out of that number towards each row in the gridview unitll the number you typed i...

Sending SMS using or using or
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Text out of a formview control (label, textbox, dropdownlist) in
How would I get the text or selectedvalue out of a from view control into the subject of an email? Here is my code Dim message As New MailMessage Dim server As New SmtpClient("") Dim fromAddress As New MailAddress("") message.Subject = (Label(frmNewQCI.FindControl("P1CategoryLabel").Text)) message.Body = "New QCI Created" message.To.Add("") message.From = fromAddress server.Send(message)   It is underlining Label and saying   'Label' is a type and cannot be used as an expression.  It's also underlining the rest an...

Using the Textbox.Text on Dynmaicly Created Textboxes in VB.Net
I found a script that i modified to create textbox fields Dynamicly.  I am now faced with the delimia of figuring out a way to pull the data in those dynamicly created fields.  Since they are not defined, I have not found a way to use a variable to pull the data. Here is the code .aspx   <%@ Page Language="VB" AutoEventWireup="false" CodeFile="DynamicTextboxes.aspx.vb" Inherits="DynamicTextboxes" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

VB.NET UltraLite and DataGrid with .NET FrameWork
hi, i need use Ultralite database with Vb.NET in a PDA with Pocket PC 2002 i need asociate Datagrid with a source, this source is a ultralite table what is the best way? i try with this code but don�t work Dim myTable As UltraLite.Table = Connection.GetTable(TablasU) DataGrid1.DataSource = myTable Thanks, Miguel Machado Please visit codeXchange for samples demonstrating the use of a DataGrid with UltraLite. The samples you are looking for are called "UltraLite...

Both C# ASPX pages and VB.NET ASPX in single VB.NET Web Applcation Template
Hi.. Is it possible to have both c# pages and VB pages in same Webapplication, what i chose is VB.NET Web application Template. With Thanks, Jaya.... I don't see why you couldn't, but for the sake of consistency I don't know why you would want to do this. When you choose a C# or VB.NET application template(I'm assuming you're using VS or WebMatrix), it simply creates a .aspx file that includes a page directive that specifies the page language. If you created a C# template but want to use VB.Net instead, you need to go from: <%@ Page Language="C#" .... to...

Access Net work mapped drive VB.NET
Hi I have a docuemnt mangemnt system coded in VB.NET. The system sometimes needs to get documents from Network mapped drive and shared drives. In development machine everything works fine. But when I moved the code to Test serever, it could not access the mapped drives. I tried all security settings. But still could not. I tried unc path, but it throws In valid user exception. Can anybody help m eto solve this issue. Thank you Jikk Hi Jikk, What login is your app running under? Whichever it is, it has to have permission to access the network, which ASPNET doesn'...

converting to from offered me some sample code when I signed up with them the only problem is the sample code is in but my page that they type all of their credit card into is <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage(""); } private String readHtmlPage(string url) { ...

accessing template column textbox of datagrid
I have used datagrid and template column.I have used textbox on one templateitem.I have to access value value from this textbox.How can i access it.I have used following code:<form id="form1" runat="server">        <asp:Button ID="Button1" runat="server" Text="Button" />          <asp:Button Text="check button" ID="show" runat="server"/>        <asp:GridView ID="GridView1" runat="server">        <Columns>  &nb...

event on a datagrid column with VB.NET
Hello, How can we apply an event on a datagrid column ? With C#, I can edit the datagrid property and set : datagrid1_CancelCommand  on CancelCommand That will generate this code:</p> <p>private void InitializeComponent(){&nbsp;&nbsp;&nbsp; this.datagrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.datagrid1_CancelCommand); But  I cannot have this with VB.NET  ! Strange How can we do this with VB.NET  ?  f...

How do I total the column of a datagrid, in ?
  Hey Everybody... I have 1 column in my datagrid that needs to be added up to get the total.  The column is called "TotalMoney". I use VB.NET for code behind....   would someone give me an overview as to how I can do this ? I don't need the result in the footer or anything like that,  I just need to be able to show the value on a Label somewhere on the page.    **********************Newbie 4-Eva  Dim adpt As SqlDataAdapter        Dim dt As DataTable        Dim total As Int3...

How to access a template column in a datagrid control
I have a DataGrid control on a web form with a template column. How can I access the dropdownlist column "ddlusertype" from my c# code? I need to bind it with a DataTable. Please help, thanks! Here is my code <Columns> <asp:BoundColumn DataField="rolName" HeaderText="User Type"></asp:BoundColumn> <asp:BoundColumn DataField="rolDescription" HeaderText="Description"></asp:BoundColumn> <asp:BoundColumn DataField="gtyAbbr" HeaderText="Client Type"></asp:B...

Calculation column in datagrid (VB.NET)
Hi, I have a datagrid on my website that has two columns in it with integer values, what i want to know is how i can add another column that calculates the percentage of the two other columns. For example ... Name...........|Hrs Worked.......|Hrs Absent.......|Percentage ---------------+------------------+-----------------+-------------------- Joe Bloggs....|10....................|5.....................|50% ---------------+------------------+-----------------+-------------------- Now the name, hrs worked and hrs absent are all pulled from a database and presented in the ... vs vs
just out of curiousity which looks, acts most like java? i'm still learning trying to used to but it seems that it was easier to do some stuff with java. C# is Java++ in my opinion. If you have done C or Jave you will prefer C#.Mike Schellenberger - MCAD If you are looking for language similar to java go for J#. However most code samples you find on the net will be in VB.NET and C#....

Web resources about - How to access datagrid template column textbox text in -

Want to preview our new DataGrid for Xamarin.Forms?
tl;dr Zumero.DataGrid is a Xamarin.Forms control for displaying data in rows and columns. If you would be interested in testing and previewing ...

Mad King DataGrid
This post is about scrolling in WPF and the egocentric DataGrid control. I’ll give the project background but if all you’re interested in is ...

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 295 ...

Microsoft Silverlight - Wikipedia, the free encyclopedia
Microsoft Silverlight is an application framework for writing and running rich Internet applications , with features and purposes similar to ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Casaba Security » Products » X5s Testing Tool For Finding XSS Vulnerabilities
Security analysis, consulting, development and testing partners who understand your business strategy.

CodeGuru - Microsoft developers related ideas, articles, tips, tricks, comments, downloads, and so much ...
CodeGuru is where developers can come to share ideas, articles, questions, answers, tips, tricks, comments, downloads, and so much more related ...

Caliburn Micro: WPF, Silverlight, WP7 and WinRT/Metro made easy.
A small, yet powerful framework designed for WPF, Silverlight and WP7. It implements a variety of UI patterns for solving real-world problems. ...

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 11 Jul 2012 11636: first draft of license proliferation committee report
FYI,the first draft report of the OSI's License Proliferation Committee.To join the OSI's license proliferation discuss email list, send anemail ...

Resources last updated: 1/14/2016 11:34:49 AM