在C#中更正我的小代码 [英] correcting my small code in c#

查看:78
本文介绍了在C#中更正我的小代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview和一列(复选框)
我想打印选中的项目并启用复选框,但是我的代码不起作用
这是我的代码:

I have a gridview and one of the columns (checkboxes)
I want to print the items I checked and enable the checkallbox,but my code dose not work
this is my code:

int CheckedCount = 0;
            int tripNum = -1;
            int BusNumber = 0;
            string MyDate = "";
            string MyTime = "";
            foreach (GridViewRow R in GridView1.Rows)
            {
                CheckBox C = R.FindControl("CheckBox1") as CheckBox;
                if (C != null)
                {
                    if (C.Checked)
                    {
                        CheckedCount++;
                        tripNum = int.Parse(R.Cells[1].Text);
                        BusNumber = int.Parse(R.Cells[6].Text);
                        MyDate = R.Cells[4].Text;
                        MyTime = R.Cells[5].Text;
                        if (CheckedCount > 1)
                        {
                            Console.Write("Only one trip can be selected.", Response);
                            return;
                        }
                    }
                }



我想知道的另一件事,什么是好地方[不,我不能再解决所有这些错字! — SA]放置此代码,是在(gridview)事件中还是在(button)事件中

感谢所有



other thing I want to know , What is the good palce [no, I cannot fix all those typo anymore! — SA] to put this code ,Is it in an event of (gridview) or in an event of (button)

Thanks for all

推荐答案

最好的地方是在浏览器中-可以使用jQuery简化的内容.
jQuery Gridview插件 [ http://msdn.microsoft.com/en-us/library/ms229601.aspx [ ^ ]
然后通过:
http://www.asp.net/web-forms [数据模型资源手册:适用于所有企业的通用数据模型库,修订版,第1卷 [ ^ ]

祝你好运:)
问候
Espen Harlinn
The best place would be in the browser - something that may be simplified using jQuery.
jQuery gridview plugins[^]

Web applications split their execution/logic between browser (like FireFox or IE) and web server (like IIS).

To make anything happen server side the page has to perform some sort of communication with the server (like a postback, or calling a web service). So something (like a button) in the browser has to trigger that action.

Update
Work your way through:
http://msdn.microsoft.com/en-us/library/ms229601.aspx[^]
Then go through:
http://www.asp.net/web-forms[^]

This provides a thorough grounding on the basics of .Net development and asp.net.

You might also benefit from reading:
The Data Model Resource Book: A Library of Universal Data Models for All Enterprises, Revised Edition, Volume 1[^]

Good luck :)
Regards
Espen Harlinn


这篇关于在C#中更正我的小代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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