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

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:boundcolumn
markup either


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

<!-- Datagrid declaration -->

<asp:datagrid id="dgRDs" runat="server"
AutoGenerateColumns="False" CssClass="DataGridClass">

<AlternatingItemStyleCssClass="TableCellAlternatin g"/>
<ItemStyle CssClass="TableCellNormal"/>
<HeaderStyle CssClass="TableHeader" />
<SelectedItemStyle BackColor=#999999 />

<!-- columns start here -->
<Columns>
<asp:ButtonColumn runat="server" Text="Select" CommandName="Select"/>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
HeaderText="Edit Data" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:TemplateColumn HeaderText="RD File Number">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "rd_file_no") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtRdfileno" Runat="server" Text='
<%# DataBinder.Eval(Container.DataItem,"rd_file_no") %>' />
</EditItemTemplate>
</asp:TemplateColumn>
<!-- 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:TemplateColumn> 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 1616
Do your thing in the event handler and then at the bottom of the code
block set the grid's SelectedItemIndex 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
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...
8
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...
1
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...
2
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...
2
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...
12
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...
5
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
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...
0
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,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.