如何从.net,c#中的gridview获取值 [英] how to get values from gridview in .net,c#

查看:73
本文介绍了如何从.net,c#中的gridview获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码检查产品是否可用,但是一旦单击检查可用性"按钮,我就会收到错误消息.错误如下

指定的参数超出有效值范围.
参数名称:index

我正在使用以下代码:

i am using this below code for checking product whether it is available or not but i am getting error as soon as i click on check availability button...the error is as follows

Specified argument was out of the range of valid values.
Parameter name: index

I am using the below code:

protected void chckdavail_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow gvr in show_moreDetails.Rows)
        {

            int data1 = Convert.ToInt32(gvr.Cells[7].Text);
            int data2 = Convert.ToInt32(gvr.Cells[8].Text);
            int data3 = Convert.ToInt32(gvr.Cells[9].Text);
            int data4 = Convert.ToInt32(gvr.Cells[10].Text);

            ClsPDF obj1 = new ClsPDF();
            int returnstatus = 0;
            returnstatus = Convert.ToInt32(obj1.productcheck(10, data3, data1, data2,data4));
            if (returnstatus == 1)
            {
                lbldavail.Visible = true;
                lbldavail.Text = "Available";
                lbldavail.ForeColor = System.Drawing.Color.Red;

            }
            else if (returnstatus == 2)
            {
                lbldavail.Text = "Not Available";
                lbldavail.ForeColor = System.Drawing.Color.Green;
                lbldavail.Visible = true;
            }
        }

    }

推荐答案

基于代码,它只是猜测错误的出处,因此请尝试调试应用程序并检查问题出在哪一行.它也可以位于productcheck内部,因此请记住使用调试器进入该方法.
Based on the code it''s just guessing where the error would be so try debugging the application and check on what row the problem occurs. It can also be inside the productcheck so remember to step into the method with the debugger.


这篇关于如何从.net,c#中的gridview获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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