.net运算的问题
protected void Butgw2_Click(object sender, EventArgs e)
{
if (Butgw2.CommandName== "Save ")
{
Label goods_id = (Label)DataGrid1.FindControl( "goods_id ");
Label goods_name = (Label)DataGrid1.FindControl( "goods_name ");
Label Manufacturer = (Label)DataGrid1.FindControl( "Manufacturer ");
Label batch_code = (Label)DataGrid1.FindControl( "batch_code ");
Label sale_price = (Label)DataGrid1.FindControl( "R_price_one ");
TextBox pf_price = (TextBox)DataGrid1.FindControl( "pf_price ");
TextBox amount_temp = (TextBox)DataGrid1.FindControl( "amount_temp ");
Label p_id = (Label)DataGrid1.FindControl( "p_id ");
Label dept_id = (Label)DataGrid1.FindControl( "dept_id ");
Label serial_id = (Label)DataGrid1.FindControl( "serial_id ");
Label provider_id = (Label)DataGrid1.FindControl( "provider_id ");
decimal little_sum = Convert.ToDecimal(pf_price.Text.ToString()) * Convert.ToDecimal(amount_temp.Text.ToString());//报
未将对象引用设置到对象的实例。
string addtime = Session[ "bill_id "].ToString();
string UserID = Session[ "LogID "].ToString();
是否语法有问题????
------解决方案--------------------注意一个前提 :如果要使用findcontrol方法,对于datagrid的话,那么该控件所在列应该是模版列!!!且其itemtemplate里面存在相应的控件!!!!
如果你的按钮是在datagrid外面
那么应该
string goods_id = (Label)DataGrid1.Items[0].FindControl( "goods_id“).Text;