My code:
public void FillMaxBankCode()
{
try
{
DataSet ds = new DataSet();
ds = bol.SelectMaxBankCode();
string j = ds.Tables[0].
If you want to ensure that the value is an integer before assigning it I suggest you use TryParse
// check if the table and row exists
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
string j = ds.Tables[0].Rows[0].ToString();
int value = 0;
if (int.TryParse(j, out value))
txtbankid.Text = value.ToString();
}