473,382 Members | 1,238 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Get value from Cell B1 and C1 from Datagrid

I'd like to display the values of cells B1 and C1 from a datagrid (i.e. the
2nd and 3rd columns of the first row) on another part of the aspx page in
large text. This is because these are important sales figures.

Is is possible to return each of those two values so I can include them in a
<% =.............. % ?

Something like <% =Datagrid1.RowColumn(1,2).Value %>

Jun 27 '08 #1
3 1339
Hi

write a public function like this...

public string ReturnCalculateValue()
{
return GridView1.Rows[0].Cells[0].Text + " " +
GridView1.Rows[0].Cells[2].Text;

}

and call it in other part of the page using

<asp:Label ID="lblsomelabel" runat="server">"<%
=ReturnCalculateValue() %>"</asp:Label>

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #2
Thanks. One of the cells is a template cell which calls a function. It is
not returning any data even though the grid displays data.
"Munna" <mu******@gmail.comwrote in message
news:c8**********************************@u12g2000 prd.googlegroups.com...
Hi

write a public function like this...

public string ReturnCalculateValue()
{
return GridView1.Rows[0].Cells[0].Text + " " +
GridView1.Rows[0].Cells[2].Text;

}

and call it in other part of the page using

<asp:Label ID="lblsomelabel" runat="server">"<%
=ReturnCalculateValue() %>"</asp:Label>

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #3
Hello Mark,

We can call FindControl method on the template cell to get the control with
the value in need. Suppose there's a Label control whose id is lblText in
the template, the ReturnCalculateValue function can be writtern in this way:

public string ReturnCalculateValue()
{
Label lbl =
(Label)GridView1.Rows[0].Cells[0].FindControl("lblText");
return lbl.Text;
}

Regards,
Jialiang Ge (ji****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

Jun 27 '08 #4

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

Similar topics

3
by: Dav | last post by:
I have a Winform with a derived datagrid and a button that adds a row to the datagrid in its Click event. The button has a shortcut text "&New Row". When I enter a value in a datagrid cell and...
2
by: kscdavefl | last post by:
I have a column on a web page datagrid that contains a value. I want to take the value and populate another cell on the grid. If the value in cell number 6 is 0 I want to make the value in cell 1...
1
by: Blake Versiga | last post by:
When editing a datagrid (C#) I need to know if the user changed the value of cell AND what the previous value was. Is this possible? If so how do I get the previous value or at least if the...
9
by: Paul | last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like 00001,000002, ect. Just wondering how to get the text value of the cell as tempstring =...
1
by: James | last post by:
I would like to get a value in a cell for the currently selected item in a DataGrid. The catch is I do not want to use an index number to access the cell. I want to use the DataField property of...
4
by: gugu | last post by:
Hi I have a datagrid which has 20 rows and 20 columns, 15 of 20 columns are checkboxs and their headertexts, datafields are dynamic. I need to loop through the whole page to see if the specific...
3
by: Jeff | last post by:
Help.. I have been using: string sId = ((System.Web.UI.WebControls.TextBox)e.Item.Cells.Controls).Text; To get the value of a cell in my datagrid. When I set the cell to read only, I get...
0
by: Matt | last post by:
I derived my own custom class from the datagrid class. I overrode the ProcessCmdKey Function, like this, to catch the up and down arrow keys: ====== Protected Overrides Function...
3
by: John Smith | last post by:
I'm looking into this peace of code: protected void DropDown_SelectedIndexChanged(object sender, EventArgs e) { DropDownList list = (DropDownList)sender; TableCell cell = list.Parent as...
2
by: John Smith | last post by:
Will this line of the code: item.Cells.Text = "Some text..."; change only DataGrid visual value or it will also change value in the DataSource? How can I change value in DataSource? ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.