| |

VerySource

 Forgot password?
 Register
Search
View: 1166|Reply: 9

Radio or radiobutton radio in GridView? ? ? ?

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-18 12:30:02
| Show all posts |Read mode
Case 1:
If you use the radiobutton control in the gridview template column, you can implement single-selection rows through coding. When you need to write code in the page code, and it will cause the page to refresh (groupname is set to the same useless), how can I implement a single-radiobutton Button without refreshing the page? ? ?

Case two:
If radio is written in the source of the page, radio selection in gridview can be realized, and the primary key value of the row can be obtained, but the problem is: if I select a radio, I want to keep the selected state of the radio after refreshing the page , How to achieve it? ? ?


Wait online. . . . . . . . . . . . .
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-21 23:15:01
| Show all posts
Yeah, I encountered the same problem, waiting for the master to help

I like...
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-7-7 16:30:01
| Show all posts
1 Use ajax
I don’t know what kind of logic event you want to trigger, write code in the foreground, call ajax method in the background, and return false to see if you can meet your requirements

2. .net is stateless. Save the number of selected rows in viewstate, and then in the onRowDataBound event
Compare e.Row.RowIndex with him selected and see if it is possible
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-7-8 23:00:02
| Show all posts
1. Do I have to use ajax? Can be achieved without
2. I tried to save the state, but it needs to be implemented with code. Is it possible that the non-server control cannot save the state after the page is refreshed?
Reply

Use magic Report

0

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-7-9 05:15:01
| Show all posts
.aspx is written like this
<input type="radio" id="RadSelected" name="RadSelected" value='<%#Eval("job_id").ToString().Trim()%>'>
.cs written like this
Request.Form["RadSelected"].ToString()
You can achieve the effect you want
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-7-13 18:00:01
| Show all posts
This will get the value I want, but the question is how can I keep the radio selected state after the page refreshes
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-25 13:15:01
| Show all posts
No one can give the answer yet
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-28 09:45:01
| Show all posts
[Quote=Quote the reply fromyoshiki317on the 5th floor:]
.aspx write like this
<input type= "radio "id= "RadSelected" name= "RadSelected "value = '<%#Eval( "job_id ").ToString().Trim()%>'>
.cs write like this
Request.Form[ "RadSelected "].ToString()
You can achieve the effect you want
[/Quote]

You can’t do this at all. I used it to directly say that there is a potential danger. The compilation fails. . .
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-28 10:00:01
| Show all posts
[Quote=Quote the reply fromyoshiki317on the 5th floor:]
.aspx write like this
<input type= "radio "id= "RadSelected" name= "RadSelected "value = '<%#Eval( "job_id ").ToString().Trim()%>'>
.cs write like this
[color=#FF0000]Request.Form[ "RadSelected "].ToString() [/color]
You can achieve the effect you want
[/Quote]
The red part should be Request.Form.Get("RadSelected").ToString()
that's it. . .
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-28 10:15:01
| Show all posts
It is recommended to use ajax, I have done similar projects. Other methods are not ideal.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list