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

click event in gridview

maliksleo
115 100+
hi all

i want to use a button in gridview and on the click event i would like to call a function for that i did the folowing
Expand|Select|Wrap|Line Numbers
  1. Sub ridgenerator(ByVal a As String)
  2.         Session("rid") = a
  3.         MsgBox("gg")
  4.         GridView2.DataBind()
  5.     End Sub
and on my markup its as below
Expand|Select|Wrap|Line Numbers
  1. <ItemTemplate>
  2. <table style="width: 100%; text-align: left">
  3. <tbody>
  4. <tr>
  5. <td style="width: 90%">
  6. <asp:LinkButton ID="LinkButton5" runat="server" Font-Underline="False" Text='<%# Eval "name") %>' OnClick='ridgenerator<%# Eval("f_id") %>' ></asp:LinkButton></td>
  7. </tr>
  8. </tbody>
  9. </table>
  10. </ItemTemplate>
but its not working whats wrong in it please do quick response.

maliksleo
Apr 13 '09 #1
4 6546
Frinavale
9,735 Expert Mod 8TB
I'm not exactly sure what your problem is because you haven't stated it; but, MsgBox is not available in web applications.

You may want to consider placing a Label on the page and setting that Label's Text property to whatever it is you need to display:
Expand|Select|Wrap|Line Numbers
  1. Sub ridgenerator(ByVal a As String)
  2.         Session("rid") = a
  3.         messageLabel.Text = "gg"
  4.         GridView2.DataBind()
  5. End Sub
Apr 13 '09 #2
maliksleo
115 100+
@Frinavale
i m sorry for not being so clear actually my function is not being called from the grid view on the click event of that linkbutton.
i just want you all to tell me the procedure by which i can call a function on a click event from the gridview.
And i m using web application there is no problem with the msgbox the only thing is
"HOW TO CALL THAT FUNCTION FROM GRIDVIEW USING LINKBUTTON?"
i did the folowing last time but didnt succeed
Expand|Select|Wrap|Line Numbers
  1. <asp:LinkButton ID="LinkButton5" runat="server" Font-Underline="False" Text='<%# Eval("name") %>' OnClientClick='<%# folderidgenerator(Eval("f_id")) %>' >
  2. </asp:LinkButton>
  3.  
any help?
Apr 14 '09 #3
Frinavale
9,735 Expert Mod 8TB
I'm not sure if the LinkButton has been automatically generated for you (like the LinkButtons in the Header Row of the GridView used for sorting...or the edit/update/delete buttons).....

But, you should look into using the RowCommand Event. The RowCommand Event is raised whenever a control within the GridView raises an event.

Please note that you have to configure your GridView to use this event:
Expand|Select|Wrap|Line Numbers
  1.  <asp:GridView ID="GridView2" 
  2.                ...
  3.               OnRowCommand="ridgenerator"
  4.              runat="server">
  5.  
Apr 14 '09 #4
maliksleo
115 100+
Thank you very much Frinavale it solved my problem once again thanks

maliksleo
Apr 15 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: K B | last post by:
I would like to create a gridview as below: Project Name 1-1 1-2 1-3 1-4 1-5 1-6 Project 1 BLUE BLUE BLUE BLUE GREEN GREEN more projects I would like to fill the...
5
by: misra | last post by:
Hi, My form has a grid and the datasource the grid is an array. There is an event which adds records to the array and assigns the array as the datasource to the grid. When I just click on the...
0
by: Riaaaa | last post by:
I have created the form for entering the company details with its general information in asp.net C# 2005. I have two buttons that form on the submit click event it should saw the newly / last...
4
by: SEliel | last post by:
Hello everyone: I'm programming a custom GridView, adding column by column dynamically. Every column is a TemplateField, and I've made a class hierarchy for each template (TextColumnTemplate,...
1
by: eaocomp | last post by:
How do I trigger a single or double-click events when a user clicks a column within the gridview. I want the event to trigger and open a pop-up page related to the selected column. There are no...
4
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This...
0
by: ADN | last post by:
Hi, I am currently extending the GridView control and would like to add a button to the GridView so that it will automatically render one button at the top of the grid. I have a click event for...
1
by: ADN | last post by:
Hi, I am currently extending the GridView control and would like to add a button to the GridView so that it will automatically render one button at the top of the grid. I have a click event for...
4
by: SAL | last post by:
Hello, I'm working, basically my first, AJAX page and am having a few problems. One is that the Click event for a button I have in UpdatePanel1 is not getting called. I've tried with the button...
4
by: vineetbindal | last post by:
Hi all, I have a gridview, when onselectedindexchanged in fired. i want to convert the selected row's column's into dropdown so that user can select the new value and update it. please tell me...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.