473,385 Members | 1,324 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,385 software developers and data experts.

Getting Control ID of buttons in Buttoncolumn in a Datagrid

Hi ,
I hav a buttoncolumn(pushBackButton) in my datagrid. And on click of every button i want to call different methods(server side).

Kindly help me out..!!!!!!!!
Thnx,
Rameshwar,Govindu.
---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 18 '05 #1
3 2742
Use UniqueId property.

Eliyahu

"DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
Hi ,
I hav a buttoncolumn(pushBackButton) in my datagrid. And on click of every button i want to call different methods(server side).
Kindly help me out..!!!!!!!!
Thnx,
Rameshwar,Govindu.
---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup

engine supports Post Alerts, Ratings, and Searching.
Nov 18 '05 #2
Based on what you've described, you don't really need to worry about the ID
of the button. You want to set the CommandName and CommandArgument (if
needed) properties of the button. In your event handler for the ItemCommand
event, test the value of the CommandName property and call the appropriate
method based on the result.

[C#]
protected void TestGrid_OnItemCommand(Object sender,
DataGridCommandEventArgs e)
{
switch(e.CommandName)
{
case "Command1":
Method1():
break;
case "Command2":
Method2();
break;
default:
Response.Write("Nothing Defined!");
break;
}
}

"DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
Hi ,
I hav a buttoncolumn(pushBackButton) in my datagrid. And on click of every button i want to call different methods(server side).
Kindly help me out..!!!!!!!!
Thnx,
Rameshwar,Govindu.
---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup

engine supports Post Alerts, Ratings, and Searching.
Nov 18 '05 #3
Try branching inside the routine called from the button click rather than
attempting to call different routines. In other words, you know the
reasoning behind the different events being called (first click, second
click, or similar), so you can branch based on that. For example (C#):

//At top of page (declarations)
protected int clickNumber = 0;

private void Button1_Click(Object sender, EventArgs e)
{
'Set click number higher for this click
'NOTE: can do this after, if you want 0 to be your start
clickNumber += 1;

switch(clickNumber)
{
case 1:
//Code on first click
break;
case 2:
//Code on second click
break;
case 3:
//Code on third click
break;
default:
//Code on all other clicks
break;
}
}

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
Hi ,
I hav a buttoncolumn(pushBackButton) in my datagrid. And on click of every button i want to call different methods(server side).
Kindly help me out..!!!!!!!!
Thnx,
Rameshwar,Govindu.
---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup

engine supports Post Alerts, Ratings, and Searching.
Nov 18 '05 #4

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

Similar topics

6
by: Jon | last post by:
Hello, I have a datagrid and the data in it is dynamically created at runtime... For iCounter = 0 To dataset.Tables(0).Columns.Count - 1 Dim objbc As New BoundColumn() With objbc .DataField...
5
by: Phil Townsend | last post by:
I need to add a button to a datagrid. I have tried using the ButtonColumn and have also tried adding a button to a templatecolumn > itemtemplate. Whatever I have tried doesn't work, nor does it...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
1
by: Raed Sawalha | last post by:
i have aspx page with user control containing a datagrid , the datagrid has TempleteColumn with checkbox in header and item ( doing multiselect task) I wondering how Can get the checkboxes status...
0
by: tperri | last post by:
here is my datagrid, within a <form> tag <asp:datagrid id="dlUserPhotos" runat="server" GridLines="None" AutoGenerateColumns="False" OnItemCommand="dlUserPhotos_ItemCommand">...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
1
by: Sathyaish | last post by:
How do you get the text of a ButtonColumn control column in a datagrid? As an example, I tried this little snippet on a test project, but it returns a null string. Private Sub...
2
by: Ray Booysen | last post by:
Hi all I have a collection of Invoices that I bind to a datagrid. Some of these invoices have been processed and you can tell this via a property in the invoice class called DateProcessed. If...
1
by: rn5a | last post by:
I have created a custom server control which is actually a Button clicking which prompts a user with a JavaScript confirm message asking him whether he would like to proceed or not. If he clicks...
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: 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:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.