473,804 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving the Cellcontent of a GridView


Hello!

I have bound a DataTable to my GridView. The DataTable has 3 Columns and
I display the Data with TemplateFields in my GridView. I have in the
first Column "LinkButton " - Field and in the other two Columns I have
"Label" - Fields!

How can I retrieve the Data of the third Column, when I click the
"LinkButton " from the same row?

I hope anyone could help me!

Here is the code from my GridView...

<asp:GridView ID="gdvData" runat="server" AutoGenerateCol umns=False
CellPadding="6" ForeColor="#333 333"
Style="left: 0px; position: relative; top: 25px" >

<Columns>

<asp:TemplateFi eld HeaderText="Nam e" >
<ItemTemplate >
<asp:LinkButt on ID="lkbName" runat="server"
Text='<%#Eval(" Name")%>' OnClick="LinkBu tton_Click"/>
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Ers tellt am" >
<ItemTemplate >
<asp:Label ID="lblCreation Time" runat="server"
Text='<%#Eval(" Erstellt am", "{0:d}")%>'/>
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Ful lName" >
<ItemTemplate >
<asp:Label ID="lblFullName " runat="server"
Text='<%#Eval(" Pfad")%>'/>
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>

</Columns>

</asp:GridView>
Regards
Sebastian
Jul 26 '07 #1
1 1447
On Jul 26, 11:13 pm, Sebastian <doug4k...@web. dewrote:
Hello!

I have bound a DataTable to my GridView. The DataTable has 3 Columns and
I display the Data with TemplateFields in my GridView. I have in the
first Column "LinkButton " - Field and in the other two Columns I have
"Label" - Fields!

How can I retrieve the Data of the third Column, when I click the
"LinkButton " from the same row?

I hope anyone could help me!

Here is the code from my GridView...

<asp:GridView ID="gdvData" runat="server" AutoGenerateCol umns=False
CellPadding="6" ForeColor="#333 333"
Style="left: 0px; position: relative; top: 25px" >

<Columns>

<asp:TemplateFi eld HeaderText="Nam e" >
<ItemTemplate >
<asp:LinkButt on ID="lkbName" runat="server"
Text='<%#Eval(" Name")%>' OnClick="LinkBu tton_Click"/>
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Ers tellt am" >
<ItemTemplate >
<asp:Label ID="lblCreation Time" runat="server"
Text='<%#Eval(" Erstellt am", "{0:d}")%>'/>
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Ful lName" >
<ItemTemplate >
<asp:Label ID="lblFullName " runat="server"
Text='<%#Eval(" Pfad")%>'/>
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>

</Columns>

</asp:GridView>

Regards
Sebastian
Hi Sebastian,
I have made a few changes to your provided code... and made worked
exactly what you want ...
<asp:TemplateFi eld HeaderText="Nam e">
<ItemTemplate >
<asp:LinkButt on ID="lkbName" runat="server"
Text='<%#Eval(" Name")%>' CommandName="Se lect" CommandArgument ='<
%#Eval("Id")%>' />
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>
in the above code you can see that i have add commandname and
commandargument ...
after that i subscripted the rowcommand event of the gridview...
and in rowcommand event handler... i did

protected void gdvData_RowComm and(object sender,
GridViewCommand EventArgs e)
{
if (e.CommandName == "Select")
{
GridViewRow row =
gdvData.Rows[Convert.ToInt32 ( e.CommandArgume nt)];
Label lbl = (Label) row.FindControl ("lblFullName") ;
string name = lbl.Text;
}
}

worked very well for me...
please give a try...

Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com

Jul 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3044
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the current_row_key of Grid1... to the objectDataSource2 parameter? (so that the second grid, gets only the information to do with current row of grid1)
5
4842
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens automatically if the data doesn't change. But if records have been added or deleted then it looks as if some code is necessary: I've done this by using GridView.SelectedValue to get the key value of the currently selected Row and then by itterating...
0
1890
by: yeltsin27 | last post by:
I need some advice on handling dynamically added controls in a GridView. My app takes an uploaded CSV file containing addresses, converts it to a DataTable, databinds the DataTable to a GridView, accepts information via dropdowns embedded in the first row of the GridView about which incoming fields should go to which database fields, and writes the data to the database. The incoming data has an arbitrary number of columns so I create...
1
9017
by: s.bussing | last post by:
Hi, I have been struggling with the GridView the whole day, but can not get this solved. The rowupdating event in my Gridview doesn't give me the new values only the old ones. In my GridView I do not use a DataSourceObject and can therefore not use e.NewValues or e.OldValues The columns used are template columns
5
2659
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are simply working with objects in memory. So, it appears as though Microsoft requires that our datamapper classes reside inside a folder called "App_Code", and NO WHERE ELSE. So, has anyone successfully been able to place their datamappers in a...
7
2881
by: Larry Bud | last post by:
I have a simple data object that returns two columns in a dataset, ID and DESC, for example. When I bind a dropdownlist to this <dataobjectmethod>, I have to manually enter the column names for the ID and value. How do I make the schema available?
0
1161
by: gnewsgroup | last post by:
Usually, when I implement the PageIndexChanging and the Sorting event handler of a GridView, I have to load the data from the db right inside either of this event handler and then bind it to the GridView, like so: protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { DataTable mytable = GetMyDataFromDb(blah, blah); GridView1.DataSource = mytable;
7
2744
by: splendid9 | last post by:
Problem in retrieving data from a XML file.......this is my code- protected void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); ds.ReadXml(MapPath("prod.xml")); DataGrid grid1 = new DataGrid(); grid1.DataSource = ds; grid1.DataBind();
0
1275
by: S_K | last post by:
Hi, I have an editible GridView that I can read the contents of each cell of the edit row as follows: int iEditIndex = GridView2.EditIndex; string strName = GridView2.Rows.Cells.Text; This works fine with the HTML of the cell set up as follows (note the readonly="True"):
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.