| |

VerySource

 Forgot password?
 Register
Search
View: 694|Reply: 6

A small problem with GridView

[Copy link]

2

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-23 15:00:01
| Show all posts |Read mode
Which elder brother can give detailed guidance on how to get the key values ​​of the current row of gridview?
Reply

Use magic Report

2

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-2 19:45:01
| Show all posts
I have assigned values ​​to DataKeyNames. I just don't know how to read the value.
Reply

Use magic Report

2

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-2 20:15:01
| Show all posts
My original code is:

        SqlConnection con = DB.createConnection();
        SqlDataAdapter sda = new SqlDataAdapter();
        sda.SelectCommand = new SqlCommand("select * from memo",con);
        DataSet ds = new DataSet();
        sda.Fill(ds, "memo");
        GridView1.DataKeyNames = new string[] {"memoID" };
        GridView1.DataSource = ds.Tables["memo"];
        GridView1.DataBind();
        GridViewRow row = new GridViewRow();
         Give advice.
Reply

Use magic Report

0

Threads

43

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-7-3 01:15:01
| Show all posts
GridViewID.DataKeys.Item(e.RowIndex).Value
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-3 02:00:02
| Show all posts
What are you doing with this! Any functions!
Haven't all the people in gridview already written Microsoft! No need to write a line of code to delete or modify!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-5 06:45:02
| Show all posts
\Microsoft all write good? It seems to be to write and pull an event binding, to achieve it seems to be written by\yourself
Reply

Use magic Report

2

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-18 23:45:01
| Show all posts
Haha, I feel that directly using Microsoft's own binding flexibility is a bit poor, but now I can get the key value, thank you for participating.
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