如何将选定的gridview行索引存储到数组中 [英] how to store selected row index of gridview into array

查看:65
本文介绍了如何将选定的gridview行索引存储到数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string device = string.Empty;
           
            int[] size = new int[4];
            for (int row_val = 0; row_val < GridView1.Rows.Count; row_val++)
            {
                if (row_val == Convert.ToInt16(rowIndex1.Value))
                {
                    device = GridView1.Rows[row_val].Cells[1].Text;
                }

            }
            int k = Convert.ToInt32(rowIndex1.Value);
            TextBox2.Text = Convert.ToString(k);
            TextBox3.Text = device;



我无法获取所选网格行的行索引,但无法放入数组.我创建了数组并添加了以下代码行,如下所示:
size [row_val] = Convert.ToInt32(GridView1.rowIndex1.Value);
它给出错误:输入字符串的格式不正确"
请帮忙....我在此上浪费了很多时间....
在此先感谢...



im able to get the row index of the selected gridrow but not able to put into array. I created array and added this line of code as shown below
size[row_val] = Convert.ToInt32(GridView1.rowIndex1.Value);
it gives error: "input string is not in a correct format"
please help.... i wasted much time on it....
thanks in advance...

推荐答案

size [row_val] = Convert.ToInt32(GridView1.rowIndex1.Value);
它给出错误:输入字符串的格式不正确"


听起来像Convert.ToInt32期望一个可以转换为int的字符串值.您没有提供. GridView1.rowIndex1.Value的值是什么?
size[row_val] = Convert.ToInt32(GridView1.rowIndex1.Value);
it gives error: "input string is not in a correct format"


Sounds like Convert.ToInt32 is expecting a string value that can be converted to int. You are not providing it. What is the value of GridView1.rowIndex1.Value?


这篇关于如何将选定的gridview行索引存储到数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆