Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to read values from a datagridview cells ?

$
0
0

Hi All,

I m trying to read the value of three columns 

first one is checkedboxcolumn 

second column is textboxcolumn containing a number and I want to save it as integer

third column is textboxcolumn containing a string 

the problem I have is that whenever I try to read a value directly from a grid view it is always throwing an exception and the value of the cell is always null 

when the cell is null ?

when the cell.value is null ?

here is my code :

 command.Parameters.Add("@Active", SqlDbType.Bit).Value = (int)gvEventsType.Rows[rowIndex].Cells[gvEventsType.Columns["ActiveCol"].Index].Value;
 command.Parameters.Add("@EventTypeName", SqlDbType.NVarChar).Value = (string)gvEventsType.Rows[rowIndex].Cells[gvEventsType.Columns["EventsTypeNameCol"].Index].Value;
 command.Parameters.Add("@DefaultPromoteWeeks", SqlDbType.Int).Value = (int)gvEventsType.Rows[rowIndex].Cells[gvEventsType.Columns["PromotionWeeksCol"].Index].Value;


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>