new SE Junior Poster in Training

Hi all..
i'm working with c#..
i want to make a chart that can retrieve the data from the database..
i found one website that tell the way to make it but i dont understand the query used..
this the the link [URL=""][/URL] and the query is [CODE]SELECT CategoryName, COUNT(*) AS ProductCount FROM Products JOIN Categories ON Products.CategoryID = Categories.CategoryID GROUP BY CategoryName
anyone can help me translate this query..

1) COUNT(*) is count for the productCount or categoryName?
2) is it necessary to include the join?
3) ProductCount is the attribute that we need to create to pu the result or one of the field in the table in databse?

new SE Junior Poster in Training

I am using Ajax Slide Show extender to show my images.

Everything works fine.

Now what I want is when the anyone clicks on any particular image it should show them that particular image in another window or popup etc.

this is code when user click the image but i dont know then
<asp:ImageButton ID="imgShowImage" runat="server"
Height="300" Style="border: 1px solid black;width:auto"
AlternateText="" onclick="imgShowImage_Click"/>

        <asp:Label runat="Server" ID="imageLabel1"/><br />
        <asp:Button runat="Server" ID="prevButton" Text="Prev" Font-Size="Small" />
        <asp:Button runat="Server" ID="playButton" Text="Play" Font-Size="Small" />
        <asp:Button runat="Server" ID="nextButton" Text="Next" Font-Size="Small" />

        <ajax:SlideShowExtender ID="slideshowextend1" runat="server"
            Loop="true" />

anyone plz

new SE Junior Poster in Training


now, when i download the image, the path will be in this format [CODE]C:\Users\itdept\Desktop\webmaster\image\Penguins.jpg[/CODE]

how can i make it save only the filename [CODE]Penguins.jpg[/CODE]?

this is my code
if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
byte[] imageSize = new byte[FileUpload1.PostedFile.ContentLength];
HttpPostedFile uploadedImage = FileUpload1.PostedFile;
uploadedImage.InputStream.Read(imageSize, 0, (int)FileUpload1.PostedFile.ContentLength);
string ImagePath = FileUpload1.PostedFile.FileName.Trim();


new SE Junior Poster in Training

hi all..
i'm working with slide show extender..
i'm referred to this website [URL=""][/URL] on how to make it..

it is completely tell the way to make it but i want to modified it to make it suitable with my requirement.. this is the code

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
//using FidesTech;

public partial class slideShowExtender2 : System.Web.UI.Page
private static DataTable tblData = new DataTable();
protected void Page_Load(object sender, EventArgs e)
if (this.IsPostBack)return;
SqlConnection db = new SqlConnection();
string strSQL = "SELECT * FROM image";
SqlConnection conn = new SqlConnection("Server=(local); Database=test; user id=sa; password=itdept");
SqlCommand comm = new SqlCommand(strSQL, conn);
SqlDataAdapter da = new SqlDataAdapter(comm);
tblData = new DataTable();
// set the initial image
if (tblData.Rows.Count > 0)
string info = tblData.Rows[0]["imagePath"].ToString();
string[] arInfo = new string[2];
// define which character is seperating fields
char[] splitter = { '/' };
arInfo = info.Split(splitter);
[B]imgShowImage.ImageUrl = "image/" + arInfo[2];[/B] }
public static AjaxControlToolkit.Slide[] GetSlides()
AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[tblData.Rows.Count];
string imagepath = "";
for (int i = 0; i < tblData.Rows.Count; i++)
DataRow dr = tblData.Rows[i];
string info = dr["imagePath"].ToString();
string[] arInfo = new string[1];
// define which character is seperating fields
char[] splitter = { '/' };
arInfo = info.Split(splitter);
imagepath = arInfo[2];
slides[i] = new AjaxControlToolkit.Slide("image/" + imagepath, "Image name", "Image Description");
return slides;
protected void imgShowImage_Click(object sender, ...

thanks for ur response..
yes, it is client computer and i'm using file asp:upload..

if i make it like you suggest, the path in my db is like this

is it true? previous post is not clearly define what actually i need..
1) how to make the splitter from '\' to '/'
2) how to make a short path '~/image/Desert.jpg' instead of 'C:\Users\itdept\Desktop\webmaster\image\Desert.jpg'

the coding now is like this
protected void btnUpload_Click(object sender, EventArgs e)
string strDescription = txtName.Text.ToString();
if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
byte[] imageSize = new byte[FileUpload1.PostedFile.ContentLength];
HttpPostedFile uploadedImage = FileUpload1.PostedFile;
uploadedImage.InputStream.Read(imageSize, 0, (int)FileUpload1.PostedFile.ContentLength);
//string ImagePath = FileUpload1.PostedFile.FileName;
//string ImagePath = Server.MapPath("~/image/" + FileUpload1.FileName);
string[] ImagePath = FileUpload1.PostedFile.FileName.Split('/');
SqlConnection con = new SqlConnection("Server=(local); Database=test; user id=sa; password=itdept");

        // Create SQL Command 
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "INSERT INTO image(imageView,Description,imagePath)" + " VALUES (@imageView,@Description,@imagePath)";
        cmd.CommandType = CommandType.Text;
        cmd.Connection = con;

        SqlParameter Description = new SqlParameter("@Description", SqlDbType.VarChar, 50);
        Description.Value = strDescription.ToString();

        SqlParameter UploadedImage = new SqlParameter ("@imageView", SqlDbType.Image, imageSize.Length);
        UploadedImage.Value = imageSize;

        SqlParameter imagePath = new SqlParameter("@imagePath", SqlDbType.NVarChar, 50);
        imagePath.Value = ImagePath.ToString();

        int result = cmd.ExecuteNonQuery();
        if (result > 0)
        lblMessage.Text = "File Uploaded";


new SE Junior Poster in Training

hi all, i'm going to make an upload picture into database.. in run successfully but now it will store as
but i just want to make it like this
is it possible?

actually i cannot how all those thing work..can you show me some sample code?

but is that actually request from my client =(

new SE Junior Poster in Training

Hi all..
i want to create a banner in my website using and ajax..
banner will consist of many banners and have the paging under the banner that moving y itself.. what we call it? i cannot find any other example yet because i dont know the name of that application..

new SE Junior Poster in Training

Hi all,
i havw make a page for user i'm uisng


[/CODE] to make a validation but not enough space.. anybody have any suggestion to make a validation rather than diaplay the error message? i'm thinking about just red bold the textbox but not found yet.. anybody knows?


i see..
so, is there any validation for that error?
any suggestions?

in the usp also's happens only if i'm insert 9999999999

new SE Junior Poster in Training

Hi all,
i'm doing a program using c# in creating an insert page..
i want to insert the zip code into the databse and have been validate using validation expression..


[/CODE] when i insert "999999999", it will giving me an error said [CODE] error converting data type nvarchar to int. [/CODE] but for the other zip code, it will insert successfully.. any help plz?

protected void Page_Load(object sender, System.EventArgs e)
if ( !(ViewState["ActiveTabIndex"] == null) && (! (sender == null)))
if (sender.GetType().ToString().Equals("AjaxControlToolkit.TabContainer"))
((AjaxControlToolkit.TabContainer)sender).ActiveTabIndex = (int)ViewState["ActiveTabIndex"];


protected void MyTabContainer_ActiveTabChanged(object sender, EventArgs e)
    ViewState["ActiveTabIndex"] = MyTabContainer.ActiveTabIndex;


this is what i have tried, but did't work..
can you explain a little bit more

new SE Junior Poster in Training

i have a problem with my tabcontainer that once user click the tab, it will not remains the tab but goes to the default tab..
This is my code

if(@sqltype = 'datagrid')
from ms_Company C, ms_Code D
where C.CmpStatusCode = D.CodID
this is what i have done, is it possible?

new SE Junior Poster in Training

Hi all,
i have a problem with my datagrid attribute "OnPageIndexChanged="gridedit_PageIndexChanged""...
for example if i have 2 page and the second page contain only one record.. if i want to delete the record, this error appear..
anyone can help me plz..

Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.

i have continued my research and found the solution..tq

new SE Junior Poster in Training

Hi all,
i need some help in c# in order to display the attrtibute that is not in the same table..
i have a table COMPANY and company table, i have attribute called CmpStatusCode that just display in int (input by ddl which is selectedvalue ex: 1,2,3)..but in CODE table, there are definition for that selectedvalue (ex: 1=active , 2=not active).. what should i do to display the value of "active" by refering to 1,2,3? i'm using usp..
i'm using datagrid to display the data..

[/CODE] this is my usp [CODE] begin SELECT CmpID, CmpCode, CmpName, CmpEffDate, CmpExpDate, CmpStatusCode from ms_Company end [/CODE] now, when the page is build, value for CmpStatusCode will be in 1,2,3.. i could not find the way to display the value for 1,2,3 that need to be refer in table code.. in Code table, the attribute that explain the CmpStatusCode is CodCode.. anybody please help me.. sorry for the bad english.. i dont know how to explain it:sad:
new SE Junior Poster in Training

Hi all,
now i'm working to convert html to pdf in
i don't have any idea to make it..
now i have this code to convert it but have a problem..
anybody please help me see thid code or send me link as a guide..
i'm using iTextSharp to convert it
protected void btnSubmit_Click(object sender, EventArgs e)
//create document
Document document = new Document();
//writer - have our own path!!! and see you have write permissions...
PdfWriter.GetInstance(document, new FileStream(Server.MapPath("/") + "WordDoc/" + "parsetest.pdf", FileMode.Create));

        //html -text - can be from database or editor too
        String htmlText = "<font  " +
       " color=\"#0000FF\"><b><i>Title One</i></b></font><font   " +
       " color=\"black\"><br><br>Some text here<br><br><br><font   " +
       " color=\"#0000FF\"><b><i>Another title here   " +
       " </i></b></font><font   " +
       " color=\"black\"><br><br>Text1<br>Text2<br><OL><LI>hi</LI><LI>how are u</LI></OL>";

        //make an arraylist ....with STRINGREADER since its no IO reading file...
        [U]ArrayList htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);[/U]

        //add the collection to the document
        for (int k = 0; k < htmlarraylist.Count; k++)

        document.Add(new Paragraph("And the same with indentation...."));

        // or add the collection to an paragraph 
        // if you add it to an existing non emtpy paragraph it will insert it from
        //the point youwrite -
        Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder"
        mypara.IndentationLeft = 36;
        [U]mypara.InsertRange(0, htmlarraylist);[/U]
    catch (Exception exx)

i have a problem with underline coding..

Thanks in advance

Thanx a lot rohan =) i had solved it..

This is the code i'm using now that given the error..
public void SearchData(string CmpID)
//Define Class gdex
gdexClass gd = new gdexClass();

    //Open Database Connection 
    SqlConnection sqlconnection = gd.GetConnection();

    //Define Store Procedure
    SqlCommand Cmd = new SqlCommand("usp_TbCompany_sd", sqlconnection);
    Cmd.CommandType = CommandType.StoredProcedure;

    //Bind Data from tbe control to Stored Procudure 
    Cmd.Parameters.AddWithValue("@CmpID", CmpID);
    //Cmd.Parameters.AddWithValue("@StatCode", ddlCmpStateCode.SelectedValue);

    //Define one SqlDataReader 
    SqlDataReader objDR;
    objDR = Cmd.ExecuteReader(); // here procedure gets execute
    if (objDR.Read())

        txtCmpStateCode.Text = objDR["CmpStateName"].ToString();

        ddlCmpStateCode.SelectedValue = ((ListItem)ddlCmpStateCode.Items.FindByValue(objDR["CmpStateCode"].ToString())).Value;
        ((ListItem)ddlCmpStateCode.Items.FindByValue(objDR["CmpStateCode"].ToString())).Selected = true;

        ListItem li = ddlCmpStateCode.Items.FindByValue(objDR["CmpStateCode"].ToString());
        if (li != null)
            ddlCmpStateCode.SelectedValue = li.Value;
            li.Selected = true;

        txtCmpEffDate.Text = objDR["CmpEffDate"].ToString().Substring(0, 10);
        txtCmpExpDate.Text = objDR["CmpExpDate"].ToString().Substring(0, 10);
        txtCmpDBlink.Text = objDR["CmpDBlink"].ToString();
    // complete close datareader.



usp_TbCompany_sd = contain all information about the company but does not contain record of state
Error = NullReferenceException: Object reference not set to an instance of an object
i have added the latest code, it doesnt read it and still give the same error

Thanks again..i have tried this code but error apperar
Object reference not set to an instance of an object.

May be this is because of the record from ddlCmpStateCode is taken form other i right?

this is my stored procedure
ALTER PROCEDURE [dbo].[usp_TbCompany_sd]

@CmpID nvarchar(10)



from Tb_Company 


should i select from other table too? which is table state that store the record state..
but there is no CmpID in table state

thank you very much..
i also want to apply this code to dropdownlist but it not display any data.. i have make some changes to selected.value but also cannot make it..

txtCmpCode.Text = objDR["CmpCode"].ToString();
txtCmpName.Text = objDR["CmpName"].ToString();
txtCmpAddr1.Text = objDR["CmpAddr1"].ToString();
txtCmpAddr2.Text = objDR["CmpAddr2"].ToString();
txtCmpCityCode.Text = objDR["CmpCityCode"].ToString();
txtCmpCityName.Text = objDR["CmpCityName"].ToString();
txtCmpZip.Text = objDR["CmpZip"].ToString();
ddlCmpStateCode.SelectedValue = objDR["CmpStateCode"].ToString();

new SE Junior Poster in Training

now i'm working with c#.. i want to view the data from database in the textbox in order to make editing to the data is avaiable..but i'm using user stored procedure..

now this is my code where i want to display the data..

Company Code :

i just make some changes to your code and now it works..

string strCompCode = Request.QueryString["comp_code"];

thank you very much rohand =)

Thanks fro your response..
but, i should put it in aspx.cs right?
i had put in page_load but error
non-invocable member 'System.web.HttpRequest.QueryString' cannot be use like a method..

anything should i put in together?