fereshte22
شنبه 17 مرداد 1388, 18:34 عصر
سلام
من برای ویرایش اطلاعات درگریدویوازروش زیراستفاده کردم
protected void GridView_Category_SelectedIndexChanged(object sender, EventArgs e)
{
Label Label_ID = (Label)GridView_Category.Rows[GridView_Category.SelectedIndex].Cells[5].FindControl("Label_ID");
string Information = rrClass.ppp_pppDetails(Int32.Parse(Label_ID.Text)) ;
if (Information != "")
{
string[] data = Information.Split(';');
name.Text = data[0];
explain.Text = data[1];
Label_FileName.Text =data[2];
if (data[3] == "fa")
CheckBoxList1.SelectedIndex = 0;
else
CheckBoxList1.SelectedIndex = 1;
explain1.Text = data[4];
}
وکلاس را به صورت زیرتعریف کردم
public static string ppp_pppDetails(int ID)
{
string ConnectionString = SafaConnectionString.ConnectionString;
SqlConnection Connection = new SqlConnection(ConnectionString);
SqlCommand Command = new SqlCommand("product_GetproductByID", Connection);
Command.CommandType = CommandType.StoredProcedure;
Command.Parameters.AddWithValue("ID", ID);
Connection.Open();
SqlDataReader RecordSet = Command.ExecuteReader();
if (RecordSet.HasRows)
{
RecordSet.Read();
string name = RecordSet["name"].ToString();
string explain = RecordSet["explain"].ToString();
string imageurl = RecordSet["imageurl"].ToString();
string lang = RecordSet["lang"].ToString();
string explain1 = RecordSet["explain1"].ToString();
string AddedDate = RecordSet["AddedDate"].ToString();
Connection.Close();
RecordSet.Close();
return (name + "|" + explain + "|" + imageurl + "|" + lang + "|" + explain1 + "|" +AddedDate );
}
else
{
Connection.Close();
RecordSet.Close();
return "";
}
}
این کدی بودکه اقای فتح الهی درپروژه خودشون استفاده کردم ومن ازش استفاده کردم و جواب گرفتم ولی درکدبالا که برای جدول محصولات خوداستفاده می کنم با خطای زیر مواجه شدم
درخط زیر
explain.Text = data[1];
Index was outside the bounds of the array
همه چیزرا مثل کدهای قبلی استفاده کردم ولی دراین مورد این خطا را میگیره
من برای ویرایش اطلاعات درگریدویوازروش زیراستفاده کردم
protected void GridView_Category_SelectedIndexChanged(object sender, EventArgs e)
{
Label Label_ID = (Label)GridView_Category.Rows[GridView_Category.SelectedIndex].Cells[5].FindControl("Label_ID");
string Information = rrClass.ppp_pppDetails(Int32.Parse(Label_ID.Text)) ;
if (Information != "")
{
string[] data = Information.Split(';');
name.Text = data[0];
explain.Text = data[1];
Label_FileName.Text =data[2];
if (data[3] == "fa")
CheckBoxList1.SelectedIndex = 0;
else
CheckBoxList1.SelectedIndex = 1;
explain1.Text = data[4];
}
وکلاس را به صورت زیرتعریف کردم
public static string ppp_pppDetails(int ID)
{
string ConnectionString = SafaConnectionString.ConnectionString;
SqlConnection Connection = new SqlConnection(ConnectionString);
SqlCommand Command = new SqlCommand("product_GetproductByID", Connection);
Command.CommandType = CommandType.StoredProcedure;
Command.Parameters.AddWithValue("ID", ID);
Connection.Open();
SqlDataReader RecordSet = Command.ExecuteReader();
if (RecordSet.HasRows)
{
RecordSet.Read();
string name = RecordSet["name"].ToString();
string explain = RecordSet["explain"].ToString();
string imageurl = RecordSet["imageurl"].ToString();
string lang = RecordSet["lang"].ToString();
string explain1 = RecordSet["explain1"].ToString();
string AddedDate = RecordSet["AddedDate"].ToString();
Connection.Close();
RecordSet.Close();
return (name + "|" + explain + "|" + imageurl + "|" + lang + "|" + explain1 + "|" +AddedDate );
}
else
{
Connection.Close();
RecordSet.Close();
return "";
}
}
این کدی بودکه اقای فتح الهی درپروژه خودشون استفاده کردم ومن ازش استفاده کردم و جواب گرفتم ولی درکدبالا که برای جدول محصولات خوداستفاده می کنم با خطای زیر مواجه شدم
درخط زیر
explain.Text = data[1];
Index was outside the bounds of the array
همه چیزرا مثل کدهای قبلی استفاده کردم ولی دراین مورد این خطا را میگیره