views:

9

answers:

0

Hi,

Stage1

My web portal checks if there is a csv file selected and then uploads a csv file through file upload option saving i

tonto a tempdatabase on sql Server and displays the data on the grid view. The grid view contain fixed 29 columns with a hyperlink named (view)

and a check field.

Stage 2 & 3

What I want is, once the file is uploaded and displayed on the datagrid view, the system should check each

row and check if the mandatory fields are filled or not, if they are not filled then the system

should change Status column in the database to fatal for that particular row, and the user can then click on the hyperlink (view)

on that particular row to see the error(which mandatory fields are not filled). Once all the rows of the grid view has no errors(Status column is ok

for all the rows then the user can check all the fields by clicking on check all button and submit the data to be uploaded on

the sql server.

I have managed to complete stage 1 but i am struggling with stage 2 and stag3. I can check the rows by:

view plaincopy to clipboardprint? protected void InsertFile_btn_Click(object sender, EventArgs e)

     {  

         DataTable dt = this.ExcelToDatatable_dt;  

         int totalRows = dt.Rows.Count;  

         //int totalRowsInserted = 0;  

         String result = "";  

         string[] posList;  



         posList = positionList;  



         foreach (DataRow row in dt.Rows)  

         {   //foreach (DataColumn col in dt.Columns)  

             //Message_ltr.Text += row[col].ToString() + "<br />";  

             //Message_ltr.Text += row[0].ToString() + "<br />" + row[1].ToString() + "<br />" + row[2].ToString() + "<br />" + row[3].ToString() + "<br />";  

             if ((row["DDIREF"].ToString() != null) && (row["DDIREF"].ToString()!=""))  



                 try  

                 {  

                     result = fn.InsertNewDDIsTemporary_Proc(  

                                       row["DDIREF"].ToString()                     //  String DDIREF_P  

                                     , row["Sortcode"].ToString()                  //  String Sortcode_P  

                                     , row["AccountNo"].ToString()                 //  String AccountNo_P  

                                     , row["AccountName"].ToString()               //  String AccountName_P  

                                     , strCompanyID_V                              //  String CompanyID_P  

                         //, (positionList[3].ToString()) ?? row["CompanyName"].ToString()               //  String CompanyName_P  

                                     , (posList[5].Length > 0) ? row["CompanyName"].ToString() : "-"                //  String CompanyName_P  

                                     , (posList[6].Length > 0) ? row["ADD1"].ToString() : "-"                      //  String ADD1_P  

                                     , (posList[7].Length > 0) ? row["ADD2"].ToString() : "-"                   //  String ADD2_P  

                                     , (posList[8].Length > 0) ? row["ADD3"].ToString() : "-"                    //  String ADD3_P  

                                     , (posList[9].Length > 0) ? row["ADD4"].ToString() : "-"                      //  String ADD4_P  

                                     , (posList[10].Length > 0) ? row["Postcode"].ToString() : "-"                  //  String Postcode_P  

                                     , (posList[11].Length > 0) ? row["email"].ToString() : "-"                     //  String email_P  

                                     , (posList[12].Length > 0) ? row["CollectionDay"].ToString() : "-"             //  String CollectionDay_P  

                                     , (posList[13].Length > 0) ? row["phone"].ToString() : "-"                    //  String phone_P  

                                     , (posList[14].Length > 0) ? row["fax"].ToString() : "-"                      //  String fax_P  

                                     , (posList[15].Length > 0) ? row["Notification"].ToString() : "-"             //  String Notification_P  

                                     , (posList[16].Length > 0) ? row["ContactName"].ToString() : "-"               //  String ContactName_P  

                                     , (posList[17].Length > 0) ? row["Companycode"].ToString() : "-"              //  String Companycode_P  

                                     , (posList[19].Length > 0) ? row["First_Amount"].ToString() : "-"              //  String First_Amount_P  

                                     , (posList[20].Length > 0) ? row["Monthly_amount"].ToString() : "-"           //  String Monthly_amount_P  

                                     , (posList[21].Length > 0) ? row["Total_amount"].ToString() : "-"             //  String Total_amount_P  

                                     , (posList[22].Length > 0) ? row["NO_TRANS"].ToString() : "-"                //  String NO_TRANS_P  

                                     , (posList[23].Length > 0) ? row["FREQUENCY"].ToString() : "-"                 //  String FREQUENCY_P  

                                     , DateTime.Now //(posList[24].ToString()) ?? row["First_Collection_Date"]     //  String First_Collection_Date_P  

                         //, (posList[29].Length>0) ?  row["dateOfBirth"].ToString() : "-"               //  String dateOfBirth_P  

                                     , DateTime.Now              //  String dateOfBirth_P  

                                     , null             //  String P_REPEATED_F_P  

                                     , DateTime.Now    //  String second_collection_date_P  

                                     , (posList[28].Length > 0) ? row["type"].ToString() : "-"                   //  String type_P  

                                     , (posList[27].Length > 0) ? row["MOBILE"].ToString() : "-"                  //  String MOBILE_P  

                                     );  

                     Message_ltr.Text += "<br />" + "Result:" + result;  

                 }  

                 catch (Exception ex)  

                 {  

                     Message_ltr.Text += "<br />" + "Error:" + ex.Message;  

                 }  



             //totalRowsInserted++;  

             //if (totalRowsInserted >= totalRows) break;  

         }  



         //int totalRows = GridView1.Rows.Count;  

         //for (int r = 0; r < totalRows; r++)  

         //{  

         //    GridViewRow thisGridViewRow = GridView1.Rows[r];   

         //    Message_ltr.Text = "col1=" + thisGridViewRow.Cells[0].Text + "col2=" + thisGridViewRow.Cells[1].Text + "col3=" + thisGridViewRow.Cells[2].Text;  

         //}  

     }  

But the problem is I want to link the view hyperlink field which is in the grid view to the error messages,so that if any row has error that error shoud be linked to the view hyperlink field of that row and the user can

click on that hyperlink which should an error message on other page. Any help will be highly appreciated

enter code here

related questions