473,545 Members | 289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid 'select' button oddities

Hi folks,
I really need help with the following scenario,
I'm going to describe as well as a I can what the setup is and what I can't
understand

I'm using the framework 1.1 using ASP.net with C#

I have a datagrid that is bound to a datasource (through ADO.net) and all
that works

I haven't autogenerated the columns and I haven't used the <asp:boundcolum n
markup either


instead I have three columns preceded by two buttons and this kind of markup

<!-- Datagrid declaration -->

<asp:datagrid id="dgRDs" runat="server"
AutoGenerateCol umns="False" CssClass="DataG ridClass">

<AlternatingIte mStyleCssClass= "TableCellAlter nating"/>
<ItemStyle CssClass="Table CellNormal"/>
<HeaderStyle CssClass="Table Header" />
<SelectedItemSt yle BackColor=#9999 99 />

<!-- columns start here -->
<Columns>
<asp:ButtonColu mn runat="server" Text="Select" CommandName="Se lect"/>
<asp:EditComman dColumn ButtonType="Lin kButton" UpdateText="Upd ate"
HeaderText="Edi t Data" CancelText="Can cel"
EditText="Edit" ></asp:EditCommand Column>
<asp:TemplateCo lumn HeaderText="RD File Number">
<ItemTemplate >
<%# DataBinder.Eval (Container.Data Item, "rd_file_no ") %>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="txtRdfileno " Runat="server" Text='
<%# DataBinder.Eval (Container.Data Item,"rd_file_n o") %>' />
</EditItemTemplat e>
</asp:TemplateCol umn>
<!-- 2 more columns with exactly the same markup but pointing to differnt
fields -->

</columns>
</datagrid>

As you can see I have two Template columns per column
1 to give the unedited look and one to add a textbox (with an id) for the
edited row look
here's what I'm mystified about

I have a 'Select' Button column and Dino Esposito in his magnum opus says:
There is no need to write an ItemCommand handler, the described behavior is
built-in

i.e when you click the Select hyperlink whatever style you chose becomes the
background of the row

and indeed he's right and it does do that...

but...

it also puts the row into Edit mode even though I'm not choosing the Edit
hyperlink (which does have an event handler)

This is my question.
how can I select a row without also placing it in Edit mode

I went with the <asp:TemplateCo lumn> route because I wanted to be able to
used named text boxes, when I do an update, and not just have the Datagrid
control give a whole load of meaningless autogenerated names
if you can help me with my select Question, I'd greatly appreciate it

Regards and thanks in advance,
CharlesA

Mar 20 '06 #1
3 1634
Do your thing in the event handler and then at the bottom of the code
block set the grid's SelectedItemInd ex property to -1.

JP

Mar 20 '06 #2
It's OK, I got it,
I realized that I hadn't done my

if (e.commandName == "Edit")
in the ItemCommand event handler of the grid

all is fine now.
Mar 20 '06 #3
thanks Joey
I thought I had replied to my own original post...but it appears my reply is
not there
I figured it out.... I was doing a

switch case in the grid's ItemCommand event handler and I just needed to
wrap up the code that was used for editing inside
Case commandname== "Edit" and isolate it so that when select calls the event
handler it doesn't go into Edit mode

all is well and thanks anyway for your help
Regards,
CharlesA
Mar 20 '06 #4

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

Similar topics

8
7893
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the header of the datagrid in the "ItemDataBound" method of the grid. However, once, they are added in the grid, i seem to lose the event handler for the...
8
3039
by: Sue | last post by:
I have a datagrid populated with 6 visible read-only labels and several hidden fields. Below the datagrid, I have a table with various textboxes, dropdowns, etc. I've managed to decypher the client-side coding needed for the user to click a "select" button (HTMLButton) in column 0 of the datagrid and have the table objects auto-fill with...
1
4291
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls (watch the layout, some have child controls):
2
3171
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp, Selecting Rows by Clicking Anywhere). Private Sub DataGrid1_ItemDataBound(ByVal...
2
2426
by: Bob Hollness | last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the questions I may ask! I have a datagrid which I have populated from a database. It works great! I have added a column, via the Columns dialog box from the properties of the datagrid, on the left that contains a select button. So now, when you press the button the whole...
12
1839
by: TB | last post by:
Hi All: I am trying to create a variation on the standard datagrid, whereby the datagrid is only shown after pressing some buttons. This reason for this is that I would like to use the same datagrid for several tables, and the idea is that the button events store the the SQL select statement and the SQL update statement in view state items,...
5
6543
by: Vik | last post by:
If there are a few Select buttons in a datagrid, is there a way to distinguish in code which button was clicked? Thanks.
1
1909
by: Brock | last post by:
Thanks in advance... (you can see a screenshot of what my form looks like currently at http://www.juggernautical.com/DataGrid.jpg - the Datalist is super-imposed in 'design view' but the DataGrid is the actual running of the page) I've almost got this working (?) but need a little help. I have an .aspx page that has a DataGrid listing...
0
2711
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only, cannot serch by combine 3 table) Example I have the query table below, how do I make the code to seach based on the query from this: SELECT...
0
7398
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...
0
7656
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. ...
0
7805
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7752
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...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
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...
1
1878
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
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.